function setFocus( targetID ) 
{
	var focusTarget = document.getElementById( targetID );
  if (focusTarget.blur)
	{
		focusTarget.focus();
	}
}


function checkField ( field ) {
}


function getFileType ( fileName ) 
{		

	if (!fileName) return;		
	dots = fileName.split(".")			
	fileType = dots[dots.length-1];
	type = 'fi';
	switch ( fileType.toLowerCase() ) {
		case 'gif'	:
		case 'jpg'	:
		case 'jpeg'	:
		case 'png'	:
			type = 'im'; break;			
		default 		:
			type = 'fi'; break;
	}
	return type;
}

function switchLanguage( selectLang )
{
	var lang = selectLang;	
	var currentLang = 'eng';	
	var currentLocation = window.location.toString();
	var urlArray = currentLocation.split( /[\/\\]/ );
	var count = urlArray.length;
	var newLocation = currentLang;
	var needSwitch = false;

	for( var i=0; i<count; i++ ) {		
		switch ( urlArray[ i ] ) {
				case 'eng':
					if( lang != (currentLang ='eng') ) {
						lang = '/chi/';
						needSwitch = true;
					}
					break;
				case 'chi':
					if( lang != (currentLang ='chi') ) {
						lang = '/eng/';
						needSwitch = true;
					}
					break;				
				default: break;				
		}
	}

	if ( needSwitch ) {
		newLocation = currentLocation.replace( "/" + currentLang + "/", lang );	
		window.location = newLocation;
	}
}


function checkFileName ( f ) {
	var splitArray = f.split( /[\/\\]/ );
	var len = splitArray.length;
	f = splitArray[ len - 1 ];
	splitArray = null;
	len = f.length;
	if ( len > 50 ) {
		alert( "The file name is too long.\nMaximum of a file name: 50 Characters." );
		return false;
	} else {
		f = f.replace(".","");
		len = f.length;
		for( var i=0; i<len; i++ ) {
			if ( !f.charAt(i).match(/[a-z]|[A-Z]|[0-9]|[\s]|-|_/) ) {
				alert("Incorrect file name!\nPlease rename the file and upload again.\n");
				return false;
			}
		}
	}
	return true;
}

function setSelectedButton() 
{
	var theImg = null;	
	switch ( document.body.id ) {
		case "about_page":
			theImg = document.getElementById( "eabout" );
			theImg.src = "images/emenu_about_o.jpg";
			break;
			
		case "news_page":
			theImg = document.getElementById( "enews" );
			theImg.src = "images/emenu_news_o.jpg";		
			break;
			
		case "service_page":
			theImg = document.getElementById( "eservice" );
			theImg.src = "images/emenu_service_o.jpg";		
			break;		
			
		case "contact_page":
			theImg = document.getElementById( "econtact" );
			theImg.src = "images/emenu_contact_o.jpg";		
			break;		
			
		case "member_page":		
			theImg = document.getElementById( "emember" );
			theImg.src = "images/emenu_member_o.jpg";		
			break;		
			
		case "vehicle_page":
			theImg = document.getElementById( "evehicle" );
			theImg.src = "images/emenu_vehicle_o.jpg";		
			break;		
			
		default: break;
	}
}
