/**
 * @author Qingzhou Zhang
 */

$(document).ready(function() {

	if(navigator.userAgent.toLowerCase().indexOf("msie")!=-1)   // if contain msie = IE
			
			{	
				if(navigator.systemLanguage.toLowerCase().indexOf("cn")!=-1)
				{
					//alert(navigator.systemLanguage.toLowerCase());
					if(navigator.appVersion.toLowerCase().indexOf("msie 6.0")!=-1)
					{
						$('body').load('Content_CH_IE6.html');
					}
					else
					{
						$('body').load('Content_CH.html');
					}
					
					
				}
				else
				{
					if(navigator.appVersion.toLowerCase().indexOf("msie 6.0")!=-1)
					{
						$('body').load('Content_EN_IE6.html');
					}
					else
					{
						$('body').load('Content_EN.html');	
					}
					
				}
				
 			}
			 
	else
			{
				if(navigator.language.toLowerCase().indexOf("cn")!=-1)
				{
					//alert(navigator.language.toLowerCase());
					$('body').load('Content_CH.html');	
				}
				else
				{
					$('body').load('Content_EN.html');
				}
			}
});	
		
var menuItems=[8, 7, 7];
var currentOpen="";

function formatTXT(text){
                myText = text;
                myText = myText.replace("[para]", "</p><p>");
                myText = myText.replace("[return]", "<br>");
                myText = myText.replace("[LinkAdress_Left_F]", "<span class='urlto'><a target='_blank' href='");
                myText = myText.replace("[LinkAdress_Left_B]", "'>");
                myText = myText.replace("[LinkAdress_Right]", "</a></span>");
                return myText;
            }
            


/*
 * Function of click item content title
 */
function clickItemConTitle(menu, item, links)
{
	
	var e = 0;
	$("#item" + menu + "_Content" + item).slideDown("slow");
	
	setTimeout(function(){loadPage(links)},1000);
	
	for(i = 0; i < menuItems.length; i++)
	{
		e = i+1;
		for(j=1; j <= menuItems[i]; j++)
		{
			// Same item slide Up
			if(e == menu & j != item)
			{
				$("#item" + e + "_Content" + j).slideUp("slow");
			}
			
			// Different item hide
			if(e != menu)
			{
				$("#item" + e + "_Content" + j).hide();
			}
			
		}
	}
		
}
/*
 * Function of over and out
 */
function ItemTitleChange(m,i)
{
	$("#item" + m + "ContentTitle" + i).toggleClass("item" + m + "ContentTitle" + i + "_out");
    $("#item" + m + "ContentTitle" + i).toggleClass("item" + m + "ContentTitle" + i + "_click")
}
/*
 * Function of clickItemTitle**********************************************
 */
function clickItemTitle(parentName,currentTitleID)
	{	
		var e=0;
		currentTitle="itemTitle" + currentTitleID;
		
		if($("#" + currentTitle).hasClass(currentTitle + "_out"))
		
		{
			$("#" + currentTitle).toggleClass(currentTitle + "_out");
       	  	$("#" + currentTitle).toggleClass(currentTitle + "_click");
			$("#" + currentTitle + "_Container").slideDown("slow");
			
			// Close other Item Titles and Item Containers
			for(i=0; i<menuItems.length; i++)
			{
				e=i+1;
				if(e != currentTitleID)
				{
					$("#itemTitle" + e ).removeClass("itemTitle" + e + "_click");
					$("#itemTitle" + e ).addClass("itemTitle" + e + "_out");
					$("#itemTitle" + e + "_Container").slideUp("slow");
					
				}
			}
			
		}
		
		else
		
		{
			$("#" + currentTitle).toggleClass(currentTitle + "_click");
       		$("#" + currentTitle).toggleClass(currentTitle + "_out");
			$("#" + currentTitle + "_Container").slideUp("slow");
		}

	}
		
/*
 * 
 * Function: loadPage **********************************************
 */

//Contact.html  mouse over action
function changeContact(item)
{
	for(i=0; i<4;i++)
	{
		if( i == item)
		{
			$("#Contact" + i).hide();
			$("#Contact_Content").removeClass();
			$("#Contact_Content").addClass("contactbody" + i);
		}
		else
		{
			$("#Contact" + i).show();
		}
	}
}
function loadPage(page){
	$("#main").scrollLeft(0);
    $.get(page + ".html", {
        t: new Date()
    }, function(data){
        $("#content").html(data);
    });  
};

function loadLanguage(page)
{
	if(navigator.appVersion.toLowerCase().indexOf("msie 6.0")!=-1)
	{
		page = page + "_IE6";
	}
	$('body').load('Content_' + page + '.html');
}

