

var timeout2	= 5000000;
var closetimer2	= 0;
var ddmenuitem2	= 0;

// open hidden layer
function mopen2(id)
{	
	// cancel close timer
	mcancelclosetime2();

	// close old layer
	if(ddmenuitem2) ddmenuitem2.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem2 = document.getElementById(id);
	ddmenuitem2.style.visibility = 'visible';

}

// close showed layer
function mclose2()
{
	if(ddmenuitem2) ddmenuitem2.style.visibility = 'hidden';
}

// go close timer
function mclosetime2()
{
	closetimer2 = window.setTimeout(mclose2, timeout2);
}

// cancel close timer
function mcancelclosetime2()
{
	if(closetimer2)
	{
		window.clearTimeout(closetimer2);
		closetimer2 = null;
	}
}

function openWindow(url,name,w,h,pos,props)
{
	var _wnd,left=0,top=0
	if(name==null)name='wnd'
	if(!pos||pos=='center'){left=screen.width?(screen.width-w)/2:100; top=screen.height?(screen.height-h)/2:100}
	props='width='+w+',height='+h+',top='+top+',left='+left+(props==''?'':','+props)
	wnd=window.open(url,name,props)
	if(pos=='maximize')_wnd.resizeTo(screen.availWidth,screen.availHeight)
	if(name=='wnd'){wnd=_wnd}else{return _wnd}
}



function chkBrowser(){
// alert(navigator.appName)
// alert(parseInt(navigator.appVersion))
if (navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion) < 4 ){
	alert("Please use Microsoft IE5 or IE6 to view the website.")
}

}

function showWMFlash(id,src,strFlashVars,w,h,bgcolor){
	document.write ('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
	document.write ('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
	document.write ('WIDTH="'+w+'" HEIGHT="'+h+'" id="'+id+'" ALIGN=""> ');
	document.write ('<PARAM NAME=movie VALUE="'+src+'"> ');
	document.write ('<PARAM NAME=quality VALUE=best>');
	document.write ('<PARAM NAME=bgcolor VALUE='+bgcolor+'>');
	document.write ('<PARAM NAME=menu value=0>');
	document.write ('<PARAM NAME=scale value=noborder>');
	document.write ('<PARAM NAME=FlashVars value="'+strFlashVars+'">');
	document.write ('<EMBED src="'+src+' quality=best scale=noborder menu=0 bgcolor='+bgcolor+' ');
	document.write ('WIDTH="'+w+'" HEIGHT="'+h+'" NAME="'+id+'" ALIGN="" ');
	document.write ('TYPE="application/x-shockwave-flash" ');
	document.write ('PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" flashvars="'+strFlashVars+'"></EMBED></OBJECT>');
}

function showECQFlash(id,src,w,h,bgcolor){
	document.write ('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
	document.write ('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
	document.write ('WIDTH="'+w+'" HEIGHT="'+h+'" id="'+id+'" ALIGN=""> ');
	document.write ('<PARAM NAME=movie VALUE="flash/'+src+'"> ');
	document.write ('<PARAM NAME=quality VALUE=best> <PARAM NAME=bgcolor VALUE='+bgcolor+'> ');
	document.write ('<PARAM NAME=wmode>');
	document.write ('<EMBED src="flash/'+src+'" quality=best bgcolor='+bgcolor+' ');
	document.write ('WIDTH="'+w+'" HEIGHT="'+h+'" NAME="'+id+'" ALIGN="" ');
	document.write ('TYPE="application/x-shockwave-flash" ');
	document.write ('PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>');
}

function simpleAlert(str){
alert(str)
}

function signUpAlert(str){
alert(str)
}

function urlencode(strText) 
{
	
	var isObj;

	var trimReg;
	
	if( typeof(strText) == "string" ) 
	{

		if( strText != null ) 
		{

			trimReg = /(^\s+)|(\s+$)/g;

			strText = strText.replace( trimReg, '');

			for(i=32;i<256;i++) 
			{
				strText = strText.replace(String.fromCharCode(i),escape(String.fromCharCode(i)));
			}

		}
	}
	return strText;
}



function resizeImage(name,file,front,iwidth){

	arFile = file.split(".")
	file1 = ""
	
	for (i=0;i<=arFile.length-2;i++)
	{
		//alert(arFile[arFile.length-2]);
		file1=file1+arFile[i]
		if (i!=arFile.length-2)
		{
			file1=file1+"."
		}
		
	}
		
	file1 = file1 + "a." + arFile[arFile.length-1]	
	var today=new Date()
	var time=today.getSeconds()
	if (front){
		document.write("<img id="+name+" src="+file1+"?"+time.valueOf()+" width="+iwidth+" border=0>")
	}else{
		document.write("<img id="+name+" src="+file1+"?"+time.valueOf()+" border=0>")
	}

}

function resizeImageA(name,file,front,iwidth){
	
	arFile = file.split(".")
	file1 = ""
	
	for (i=0;i<=arFile.length-2;i++)
	{
		//alert(arFile[arFile.length-2]);
		file1=file1+arFile[i]
		if (i!=arFile.length-2)
		{
			file1=file1+"."
		}
		
	}
		
	file1 = file1 + "a." + arFile[arFile.length-1]	
	var today=new Date()
	var time=today.getSeconds()
	if (front){
		document.write("<img id="+name+" src="+file1+"?"+time.valueOf()+" width="+iwidth+" border=0>")
	}else{
		document.write("<img id="+name+" src="+file1+"?"+time.valueOf()+" border=0>")
	}

}

function resizeImage2(file){
	var image0 =new Image();
	var iHeight, iWidth 
	var today=new Date()
	var time=today.getSeconds()
	image0.src =file + "?"+time.valueOf();	

	//document.images['p1'].src=image0.src;
	// alert(image0.src)
	//  alert(image0.width)
	//	 alert(image0.height)
	if (image0.width > image0.height){
		iHeight = (100 / image0.width) * image0.height
		iWidth=100}
	else{
		iWidth = (100 / image0.height) * image0.width
		iHeight=100
	}
	// alert(iWidth)
	// alert(iHeight)
		
	document.write("<img src="+file+" border=0 width="+iWidth+" height=" + iHeight + ">")

}

function resizeImage3(name,file,front){
	arFile = file.split(".")
	file1 = arFile[0] + "a." + arFile[1]	
	var today=new Date()
	var time=today.getSeconds()
	if (front){
		document.write("<img id="+name+" src="+file1+"?"+time.valueOf()+" height=68 border=1>")
	}else{
		document.write("<img id="+name+" src="+file1+"?"+time.valueOf()+" border=1>")
	}

}

function chgCountry(){			
	if (document.all.country.options[document.all.country.selectedIndex].value=="99")
		{document.all.sOtherCountry.style.display = "inline"}
	else
		{document.all.sOtherCountry.style.display = "none"}

}

function chgProfessional(){			
	if (document.all.professional.options[document.all.professional.selectedIndex].value=="99")
		{document.all.sOtherProfessional.style.display = "inline"}
	else
		{document.all.sOtherProfessional.style.display = "none"}

}


//removed by san on 31Jul06 start
//chgReligion added by san 
/*
function chgReligion(){
	if(document.all.religion.options[document.all.religion.selectedIndex].value=="99")
		{document.all.sOtherReligion.style.display = "inline"}
	else
		{document.all.sOtherReligion.style.display = "none"}
}
*/
//removed by san on 31Jul06 end
/*
function chgJobLocation(){
	if (document.all.jobLocation.options[document.all.jobLocation.selectedIndex].value=="99")
		{document.all.sOtherJobLocation.style.display = "inline"}
	else
		{document.all.sOtherJobLocation.style.display = "none"}
}

*/


//chgNationality added by san
function chgNationality(){
	if(document.all.nationality.options[document.all.nationality.selectedIndex].value=="99")
		{document.all.sOtherNationality.style.display = "inline"}
	else
		{document.all.sOtherNationality.style.display = "none"}
}



//chgProvince added by san, wait for remove since has chgProvinceEdit and chgProvinceSearch
/*
function chgProvince(){
	if(document.all.province.options[document.all.province.selectedIndex].value=="99")
		{document.all.sOtherProvince.style.display = "inline"}
	else
		{document.all.sOtherProvince.style.display = "none"}
}
*/


//chgSubProvince added by san
function chgSubProvince(){
	if(document.all.subProvince.options[document.all.subProvince.selectedIndex].value=="999")
		{document.all.sOtherSubProvince.style.display = "inline"}
	else
		{document.all.sOtherSubProvince.style.display = "none"}
}



//removed by san on 31Jul06 start
function chgForeignPlace(){
	if(document.all.foreignPlace.options[document.all.foreignPlace.selectedIndex].value=="99")
		{document.all.sOtherForeignPlace.style.display = "inline"}
	else
		{document.all.sOtherForeignPlace.style.display = "none"}
}



//chgJobLocation added by san

function chgJobLocation(){
	if (document.all.jobLocation.options[document.all.jobLocation.selectedIndex].value=="99")
		{document.all.sOtherJobLocation.style.display = "inline"}
	else
		{document.all.sOtherJobLocation.style.display = "none"}
}


//chgBreakReason added by san
function chgBreakReason(){
	if (document.all.breakReason.options[document.all.breakReason.selectedIndex].value=="99")
		{document.all.sOtherBreakReason.style.display = "inline"}
	else
		{document.all.sOtherBreakReason.style.display = "none"}
}


//chgLoveView added by san and removed by san on 31Jul06

function chgLoveView(){
	if (document.all.loveView.options[document.all.loveView.selectedIndex].value=="99")
		{document.all.sOtherLoveView.style.display = "inline"}
	else
		{document.all.sOtherLoveView.style.display = "none"}
}


//delete by san on 1Aug06 start
// Jasmin 2006/7/21 Display textBox when user click other
/*
function chgOccupation(){			
	if (document.all.occupation.options[document.all.occupation.selectedIndex].value=="1009"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="1105"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="1206"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="1815"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="3005"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="3305"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="3509"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="4305"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="4412"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5004"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5105"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5209"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5301"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5403"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5509"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="999"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="6203"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="6608"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="7505")
		{document.all.sOtherOccupation.style.display = "inline"}
	else
		{document.all.sOtherOccupation.style.display = "none"}

}
*/	//delete by san on 1Aug06 end

// Jasmin 2006/7/21 Display textBox when user click other
/*
function chgOccupation2(){			
	if (document.all.occupation.options[document.all.occupation.selectedIndex].value=="1009"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="1105"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="1206"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="1815"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="3005"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="3305"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="3509"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="4305"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="4412"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5004"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5105"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5209"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5301"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5403"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5509"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="5701"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="6203"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="6608"
	|| document.all.occupation.options[document.all.occupation.selectedIndex].value=="7505")
		{document.all.sOtherOccupation2.style.display = "inline"}
	else
		{document.all.sOtherOccupation2.style.display = "none"}
		
}
*/

function chgOccupation(){			
	if (document.all.occupation.options[document.all.occupation.selectedIndex].value=="99")
		{document.all.sOtherOccupation.style.display = "inline"}
	else
		{document.all.sOtherOccupation.style.display = "none"}
}

function chgTitle(){			
	if (document.all.title.options[document.all.title.selectedIndex].value=="99")
		{document.all.sOtherTitle.style.display = "inline"}
	else
		{document.all.sOtherTitle.style.display = "none"}
}


//chgProvinceSearch added by san start
function chgProvinceSearch() {
	
	var tempArray;
	
	//if (document.all.province.value + "" == "0" || document.all.province.value + "" == "1" || document.all.province.value + "" == "2"
	//|| document.all.province.value + "" == "9" || document.all.province.value + "" == "32" || document.all.province.value + "" == "33"
	//|| document.all.province.value + "" == "34" || document.all.province.value + "" == "35" || document.all.province.value + "" == "36"
	//|| document.all.province.value + "" == "37" || document.all.province.value + "" == "38" || document.all.province.value + "" == "39"
	//|| document.all.province.value + "" == "99")
	//{
	//	tempArray = eval("arSubProvince" + document.all.province.value);	
	//}
	//else{
		tempArray = eval("arAllProvince.concat(arSubProvince" + document.all.province.value + ")");
	//}

	
		
	document.all.subProvince.length = 0
	for (i=0; i<tempArray.length; i+=2){		
		document.all.subProvince.options[i/2] = new Option(tempArray[i+1], tempArray[i]);
	}

	//document.all.subProvince.options[s].selected = true

}

function chgProvinceEdit() {
	
	var tempArray;
	
	tempArray = arSelect0.concat(eval("arSubProvince" + document.all.province.value));	
	
	document.all.subProvince.length = 0
	for (i=0; i<tempArray.length; i+=2){		
		document.all.subProvince.options[i/2] = new Option(tempArray[i+1], tempArray[i]);
	}


	//if(document.all.province.options[document.all.province.selectedIndex].value=="99")
	//	{document.all.sOtherProvince.style.display = "inline"}
	//else
	//	{document.all.sOtherProvince.style.display = "none"}

	//chgSubProvince()

	//document.all.subProvince.options[s].selected = true

}
//chgProvinceSearch added by san end



//delete by san on 29Jul06 start
//chgLivingPlace added by san start

function chgSubLivingPlace(){			

	/*if (document.all.subLivingPlace.options[document.all.subLivingPlace.selectedIndex].value=="999")
		{document.all.sOtherSubLivingPlace.style.display = "inline"}
	else
		{document.all.sOtherSubLivingPlace.style.display = "none"}*/

}

//delete by san on 29Jul06 start


function chgLivingPlaceSearch() {
	
	var tempArray;
	/*
	if (document.all.livingPlace.value + "" == "0" || document.all.livingPlace.value + "" == "4" || document.all.livingPlace.value + "" == "5"
	|| document.all.livingPlace.value + "" == "6" || document.all.livingPlace.value + "" == "7" || document.all.livingPlace.value + "" == "8"
	|| document.all.livingPlace.value + "" == "9" || document.all.livingPlace.value + "" == "10" || document.all.livingPlace.value + "" == "11"
	|| document.all.livingPlace.value + "" == "12" || document.all.livingPlace.value + "" == "13" || document.all.livingPlace.value + "" == "14"
	|| document.all.livingPlace.value + "" == "99")
	{
		tempArray = eval("arSubLivingPlace" + document.all.livingPlace.value);	
	}
	else{
		*/
		tempArray = eval("arAllLivingPlace.concat(arSubLivingPlace" + document.all.livingPlace.value + ")");
	//}

	document.all.subLivingPlace.length = 0
	for (i=0; i<tempArray.length; i+=2){		
		document.all.subLivingPlace.options[i/2] = new Option(tempArray[i+1], tempArray[i]);
	}

	//document.all.subLivingPlace.options[s].selected = true

}

function chgLivingPlaceSign() {
	
	var tempArray;
	
	tempArray = arSelect0.concat(eval("arSubLivingPlace" + document.all.livingPlace.value));	

	document.all.subLivingPlace.length = 0
	for (i=0; i<tempArray.length; i+=2){		
		document.all.subLivingPlace.options[i/2] = new Option(tempArray[i+1], tempArray[i]);
	}


	//delete by san on 29Jul06 start
	//if(document.all.livingPlace.options[document.all.livingPlace.selectedIndex].value=="99")
	//	{document.all.sOtherLivingPlace.style.display = "inline"}
	//else
	//	{document.all.sOtherLivingPlace.style.display = "none"}

	chgSubLivingPlace()
	//delete by san on 29Jul06 end

	//document.all.subLivingPlace.options[s].selected = true

}

function chgLivingPlaceEdit() {
	
	var tempArray;
	
	if (document.all.livingPlace.value!=0)
	{
		tempArray = eval("arSubLivingPlace" + document.all.livingPlace.value);	
		tempArray = arSelect0.concat(tempArray);
	}
	else
	{
		tempArray = arSelect0;
	}

	document.all.subLivingPlace.length = 0
	for (i=0; i<tempArray.length; i+=2){		
		document.all.subLivingPlace.options[i/2] = new Option(tempArray[i+1], tempArray[i]);
	}


	//delete by san on 29Jul06 start
	//if(document.all.livingPlace.options[document.all.livingPlace.selectedIndex].value=="99")
	//	{document.all.sOtherLivingPlace.style.display = "inline"}
	//else
	//	{document.all.sOtherLivingPlace.style.display = "none"}

	chgSubLivingPlace()
	//delete by san on 29Jul06 end

	//document.all.subLivingPlace.options[s].selected = true

}

//chgLivingPlace added by san end



//chgJobLocation added by san start

function chgSubJobLocation(){			
	
	/*if (document.all.subJobLocation.options[document.all.subJobLocation.selectedIndex].value=="999")
		{document.all.sOtherSubJobLocation.style.display = "inline"}
	else
		{document.all.sOtherSubJobLocation.style.display = "none"}*/

}


function chgJobLocationSearch() {
	
	var tempArray;
	/*
	if (document.all.jobLocation.value + "" == "0" || document.all.jobLocation.value + "" == "4" || document.all.jobLocation.value + "" == "5"
	|| document.all.jobLocation.value + "" == "6" || document.all.jobLocation.value + "" == "7" || document.all.jobLocation.value + "" == "8"
	|| document.all.jobLocation.value + "" == "9" || document.all.jobLocation.value + "" == "10" || document.all.jobLocation.value + "" == "11"
	|| document.all.jobLocation.value + "" == "12" || document.all.jobLocation.value + "" == "13" || document.all.jobLocation.value + "" == "14"
	|| document.all.jobLocation.value + "" == "99")
	{
		tempArray = eval("arSubLivingPlace" + document.all.jobLocation.value);	
	}
	else{
		*/
		tempArray = eval("arAllLivingPlace.concat(arSubLivingPlace" + document.all.jobLocation.value + ")");
	//}

	document.all.subJobLocation.length = 0
	for (i=0; i<tempArray.length; i+=2){		
		document.all.subJobLocation.options[i/2] = new Option(tempArray[i+1], tempArray[i]);
	}

	//document.all.subJobLocation.options[s].selected = true

}

function chgJobLocationEdit() {
	
	var tempArray;
	if (document.all.jobLocation.value!=0)
	{
		tempArray = arSelect0.concat(eval("arSubLivingPlace" + document.all.jobLocation.value));	
	}
	else
	{
		tempArray = arSelect0;
	}
	document.all.subJobLocation.length = 0
	for (i=0; i<tempArray.length; i+=2){		
		document.all.subJobLocation.options[i/2] = new Option(tempArray[i+1], tempArray[i]);
	}

	chgSubJobLocation()


}

//chgJobLocation added by san end

// Jasmin 2006/8/9 
function chgLocationEdit(type) {
	
	var tempArray;
	
	if (document.all.Location.value != "99")
	{
		if (type == 1)
		{
			tempArray = arSelect0.concat(eval("arSubPrimarySchool" + document.all.Location.value));	
		}
		else if (type == 2)
		{
			tempArray = arSelect0.concat(eval("arSubSecondarySchool" + document.all.Location.value));
		}
		else if (type == 3)
		{
			tempArray = arSelect0.concat(eval("arSubTertiarySchool" + document.all.Location.value));
		}
	}
	else
	{
		if (type == 1)
		{
			tempArray = eval("arSubPrimarySchool" + document.all.Location.value);
		}
		else if (type == 2)
		{
			tempArray = eval("arSubSecondarySchool" + document.all.Location.value);
		}
		else if (type == 3)
		{
			tempArray = eval("arSubTertiarySchool" + document.all.Location.value);
		}
	}

	document.all.Name.length = 0
	for (i=0; i<tempArray.length; i+=2){		
		document.all.Name.options[i/2] = new Option(tempArray[i+1], tempArray[i]);
	}
}

// Jasmin 2006/8/11 
function chgCurrentSchoolLocationEdit(type) {
	
	var tempArray;
	
	if (document.all.CurrentSchoolLocation.value != "99")
	{
		if (type == "1")
		{
			tempArray = arSelect0.concat(eval("arSubPrimarySchool" + document.all.CurrentSchoolLocation.value));	
		}
		else if (type == "2")
		{
			tempArray = arSelect0.concat(eval("arSubSecondarySchool" + document.all.CurrentSchoolLocation.value));
		}
		else if (type == "3")
		{
			tempArray = arSelect0.concat(arSubTertiarySchool);
		}
		else
		{
			tempArray = arSelect0;
		}
	}
	else
	{
		if (type == "1")
		{
			tempArray = eval("arSubPrimarySchool" + document.all.CurrentSchoolLocation.value);
		}
		else if (type == "2")
		{
			tempArray = eval("arSubSecondarySchool" + document.all.CurrentSchoolLocation.value);
		}
		else if (type == "3")
		{
			tempArray = arSubTertiarySchool;
		}
		else
		{
			tempArray = arSelect0;
		}
	}
	
	document.all.CurrentSchoolName.length = 0
	for (i=0; i<tempArray.length; i+=2){		
		document.all.CurrentSchoolName.options[i/2] = new Option(tempArray[i+1], tempArray[i]);
	}
}

// Jasmin 2006/8/11 
function chgCurrentSchoolTypeEdit() {

	var tempArray;
	
	if (document.all.CurrentSchoolType.value != "99" && document.all.CurrentSchoolType.value != "0")
	{
		tempArray = arSelect0.concat(arBackgroundLocation);	
	}
	else
	{
		tempArray = arSelect0;	
	}

	document.all.CurrentSchoolLocation.length = 0
	for (i=0; i<tempArray.length; i+=2){		
		document.all.CurrentSchoolLocation.options[i/2] = new Option(tempArray[i+1], tempArray[i]);
	}

}

function occupationLstBox(fld, val, style){
	var ar =  arSelect0.concat(arOcAccountingTitle.concat(arOcAccounting.concat(arOcAdministrationTitle.concat(arOcAdministration.concat(arOcAdvertisingTitle.concat(arOcAdvertising.concat(arOcAerospaceTitle.concat(arOcAerospace.concat(arOcAgricultureTitle.concat(arOcAgriculture.concat(arOcAirlineTitle.concat(arOcAirline.concat(arOcArchitecturalTitle.concat(arOcArchitectural.concat(arOcAthleticsTitle.concat(arOcAthletics.concat(arOcBankingTitle.concat(arOcBanking.concat(arOcBuildingTitle.concat(arOcBuilding.concat(arOcBizAnalysisTitle.concat(arOcBizAnalysis.concat(arOcBizConsultancyTitle.concat(arOcBizConsultancy.concat(arOcBizDevelopmentTitle.concat(arOcBizDevelopment.concat(arOcCallTitle.concat(arOcCall.concat(arOcChemicalTitle.concat(arOcChemical.concat(arOcCivilTitle.concat(arOcCivil.concat(arOcSecretaryTitle.concat(arOcSecretary.concat(arOcConsellingTitle.concat(arOcConselling.concat(arOcCollectionTitle.concat(arOcCollection.concat(arOcCustomerTitle.concat(arOcCustomer.concat(arOcDesignTitle.concat(arOcDesign.concat(arOcDocumentaryTitle.concat(arOcDocumentary.concat(arOcEditorialTitle.concat(arOcEditorial.concat(arOcEducationTitle.concat(arOcEducation.concat(arOcEnergyTitle.concat(arOcEnergy.concat(arOcEngineeringTitle.concat(arOcEngineering.concat(arOcEntertainmentTitle.concat(arOcEntertainment.concat(arOcEnvironmentTitle.concat(arOcEnvironment.concat(arOcFoodTitle.concat(arOcFood.concat(arOcGemsTitle.concat(arOcGems.concat(arOcManagementTitle.concat(arOcManagement.concat(arOcHealthTitle.concat(arOcHealth.concat(arOcHotelTitle.concat(arOcHotel.concat(arOcHumanTitle.concat(arOcHuman.concat(arOcInformationTitle.concat(arOcInformation.concat(arOcInsuranceTitle.concat(arOcInsurance.concat(arOcJuniorTitle.concat(arOcJunior.concat(arOcLaboratoryTitle.concat(arOcLaboratory.concat(arOcLegalTitle.concat(arOcLegal.concat(arOcLifeTitle.concat(arOcLife.concat(arOcLogisticsTitle.concat(arOcLogistics.concat(arOcManufacturingTitle.concat(arOcManufacturing.concat(arOcMarketingTitle.concat(arOcMarketing.concat(arOcMediaTitle.concat(arOcMedia.concat(arOcMedicalTitle.concat(arOcMedical.concat(arOcMerchandisingTitle.concat(arOcMerchandising.concat(arOcOrderTitle.concat(arOcOrder.concat(arOcPharmaceuticalTitle.concat(arOcPharmaceutical.concat(arOcPhotographyTitle.concat(arOcPhotography.concat(arOcPrintingTitle.concat(arOcPrinting.concat(arOcProcurementTitle.concat(arOcProcurement.concat(arOcPropertyTitle.concat(arOcProperty.concat(arOcQualityTitle.concat(arOcQuality.concat(arOcDeveopmentTitle.concat(arOcDeveopment.concat(arOcResearchTitle.concat(arOcResearch.concat(arOcSalesTitle.concat(arOcSales.concat(arOcSecurityTitle.concat(arOcSecurity.concat(arOcSocialTitle.concat(arOcSocial.concat(arOcStudentTitle.concat(arOcStudent.concat(arOcTechnicianTitle.concat(arOcTechnician.concat(arOcTopTitle.concat(arOcTop.concat(arOcTourismTitle.concat(arOcTourism.concat(arOcTradingTitle.concat(arOcTrading.concat(arOcTranslationTitle.concat(arOcTranslation.concat(arOcTransportationTitle.concat(arOcTransportation.concat(arOcUtilitiesTitle.concat(arOcUtilities))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
	lstBox3(fld,ar,val,(style=null?"class=field":style))
}

function lstBox3(lstName,ar,val,style){
	document.open()
	document.writeln("<select name=" + lstName + (style==""?"":" " +style) + ">")
	for(var i=0;i<ar.length;i+=2)
	{
		if(ar[i]=="")
		{
			document.writeln("<optgroup label=" + ar[i+1] + " style='font-style: normal;font-weight:normal;background-color:#977b89;color=ffffff'>")
		}
		else
		{
			document.writeln("<option value='"+ar[i] + "'" + (ar[i]==val?" selected":"") + "  style='font-style: normal;font-weight:normal;background-color:#ffffff;color=977b89'>" + ar[i+1] + "</option>")
		}
	}
	document.writeln("</select>")
	document.close()
}

function lstBox2(lstName,ar,val,style){
	document.open()
	document.writeln("<select name=" + lstName + (style==""?"":" " +style) + ">")
	for(var i=0;i<ar.length;i+=2)
		document.writeln("<option value='"+ar[i] + "'" + (ar[i]==val?" selected":"") + (ar[i]==""?"style='background-color:gray;color:white'":"") + ">" + ar[i+1] + "</option>")
	document.writeln("</select>")
	document.close()
					
}

function lstBox(lstName,ar,val,style){
	document.open()
	document.writeln("<select name=" + lstName + (style==""?"":" " +style) + ">")
	for(var i=0;i<ar.length;i+=2)
		document.writeln("<option value='"+ar[i] + "'" + (ar[i]==val?" selected":"") + ">" + ar[i+1] + "</option>")
		document.writeln("</select>")
		document.close()
					
}



function chkBox(name,ar,val,colNum,style){
	//var percent = 500/colNum;
	width="width=" +  120 + ""

	document.open()
	document.writeln("<table cellpadding=3 cellspacing=3 width=100% border=0 class=tbl>")

	for(var i=0;i<ar.length;i+=colNum*2){

		document.writeln("<tr>")
		
		for(var j=0;j<colNum*2;j+=2){

			if (i+j<ar.length){
				
				document.writeln("<td " + width + "><input type=checkbox name='"+name+"' value='"+ar[i+j]+"' " + (nullToEmpty(style) ==""?"":style) + (val.indexOf("|"+ar[i+j]+"|",0)>=0?" checked":"") + " > " + ar[i+j+1] + "</td>")
			}
			else{
				document.writeln("<td " + width + ">&nbsp;</td>")
			}

		}

		document.writeln("</tr>")
	}

	document.writeln("</table>")
	document.close()
}
					
					
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 wrFlash(id,src,w,h,bgcolor){
document.write ('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
document.write ('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
document.write ('WIDTH="'+w+'" HEIGHT="'+h+'" id="'+id+'" ALIGN=""> ');
document.write ('<PARAM NAME=movie VALUE="flash/'+src+'"> ');
document.write ('<PARAM NAME=quality VALUE=best> <PARAM NAME=bgcolor VALUE='+bgcolor+'> ');
document.write ('<EMBED src="flash/'+src+'" quality=high bgcolor='+bgcolor+' ');
document.write ('WIDTH="'+w+'" HEIGHT="'+h+'" NAME="'+id+'" ALIGN="" ');
document.write ('TYPE="application/x-shockwave-flash" ');
document.write ('PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>');
}

function wrTFlash(id,src,w,h,bgcolor){
document.write ('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ');
document.write ('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
document.write ('WIDTH="'+w+'" HEIGHT="'+h+'" id="'+id+'" ALIGN=""> ');
document.write ('<PARAM NAME=movie VALUE="flash/'+src+'"> <param name=wmode value=transparent /> ');
document.write ('<PARAM NAME=quality VALUE=best> <param name=menu value=false>');
document.write ('<EMBED src="flash/'+src+'" quality=high wmode=transparent bgcolor='+bgcolor+' ');
document.write ('WIDTH="'+w+'" HEIGHT="'+h+'" NAME="'+id+'" ALIGN="" ');
document.write ('TYPE="application/x-shockwave-flash" ');
document.write ('PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" menu=false></EMBED></OBJECT>');
}

function showMatchingVal(ar,val,emptyStr){
	var tmpStr = ""
	if (emptyStr) tmpStr = emptyStr
	for(var i=0;i<ar.length;i+=2)
		if (val==ar[i])	{tmpStr = ar[i+1]}
	if (tmpStr == "")
	{
		tmpStr = "其他"
	}
	document.write(tmpStr)
}

function showVal(ar,val,emptyStr){
	var tmpStr = ""
	if (emptyStr) tmpStr = emptyStr
	for(var i=0;i<ar.length;i+=2)
		if (val==ar[i])	{tmpStr = ar[i+1]}
	if (tmpStr == "")
	{
		tmpStr = "尚未透露"
	}
	document.write(tmpStr)
}

function GetVal(ar,val,emptyStr){
	var tmpStr = ""
	if (emptyStr) tmpStr = emptyStr
	for(var i=0;i<ar.length;i+=2)
		if (val==ar[i])	{tmpStr = ar[i+1]}
	if (tmpStr == "")
	{
		tmpStr = "尚未透露"
	}
	return tmpStr
}

function showValAutoMatch(ar,val,emptyStr){
	var tmpStr = ""
	if (emptyStr) tmpStr = emptyStr
	for(var i=0;i<ar.length;i+=2)
		if (val==ar[i])	{tmpStr = ar[i+1]}
	if (tmpStr == "")
	{
		tmpStr = "尚未透露"
	}
	if (tmpStr.length > 7)
	{
		tmpStr=tmpStr.substring(0,7) + "..."
	}
	document.write(tmpStr)
}

//added by san on 9Aug06 start
function showValHL(arg1,arg2){
	var tmpStr = "";
	var tmp;

	ar1 = arg1.split("|");
	ar2 = arg2.split(",");

	//alert(ar1.length);
	for (var i=0;i<ar1.length;i++)
	{
		if (tmpStr != "" && ar1[i] != "") {tmpStr=tmpStr + ", "}
		tmp = ar1[i];

		for(var j=0; j<ar2.length; j++)
		{	
			if (ar1[i] == ar2[j])
			{
				tmp	= "<b><font color=0066ff>" + tmp + "</font></b>";		
			}
		}

		tmpStr = tmpStr + tmp
	}

	if (tmpStr == "")
	{
		tmpStr = "尚未透露"
	}
	document.write(tmpStr)
}
//added by san on 9Aug06 end









//source by other website for trim function start
function trim(STRING){
STRING = LTrim(STRING);
return RTrim(STRING);
}

function RTrim(STRING){
while(STRING.charAt((STRING.length -1))==" "){
STRING = STRING.substring(0,STRING.length-1);
}
return STRING;
}


function LTrim(STRING){
while(STRING.charAt(0)==" "){
STRING = STRING.replace(STRING.charAt(0),"");
}
return STRING;
}
//source by other website for trim function end




//show highlight keyword for singer, actor, author start
//arg1 is database value, arg2 is search criteria

function showSearchFormatHL(arg1,arg2){
	
	var ignoreCaseStr1;
	var ignoreCaseStr2;
	var tmpShow;
	var tmp, len, j;
	var arLen, ar2;
	var arPosStart = new Array(); 
	var arPosEnd = new Array(); 

	tmpShow = "";
	tmp = arg1;
	tmp = tmp.replace(/\|\|/g, "");
	tmp = tmp.replace(/\|/g, ",");
	ar2 = arg2.split(",");
	
	len = 0;

	//alert(tmpShow);
	//alert(
	for (var i=0; i < ar2.length; i++)
	{
		if( trim(ar2[i]) != "" ){
			j = 0;

			ignoreCaseStr1 = tmp.toUpperCase();
			ignoreCaseStr2 = ar2[i].toUpperCase();

			while ( ignoreCaseStr1.indexOf(trim(ignoreCaseStr2), j) > -1)          //tmp.indexOf(trim(ar2[i]), j) > -1)
			{
				
				arPosStart[len] = ignoreCaseStr1.indexOf(trim(ignoreCaseStr2), j);
				arPosEnd[len] = arPosStart[len] + trim(ignoreCaseStr2).length;
				
				j=arPosStart[len++] + trim(ignoreCaseStr2).length;


			}
		}
	}

	//alert(len);
	//alert(arPosStart[1]);

	if (tmp == "")
	{
		document.write("尚未透露");
	}
	else
	{
		for (var k=0;k<tmp.length + 1;k++ )
		{
			
			for (j=0;j<len + 1; j++)
			{
				if(arPosStart[j] == k){
					//document.write("<b><font color=0066ff>");
					tmpShow = tmpShow + "<b><font color=0066ff>";}
				if(arPosEnd[j] == k){
					tmpShow = tmpShow + "</font></b>";}

					//document.write("</font></b>");}
			}

			tmpShow = tmpShow + tmp.charAt(k);
			//document.write(tmp.charAt(k));
		}

		//alert(tmpShow);
		document.write(tmpShow);
		//alert(tmpShow);
	}

}
//show highlight keyword  for singer, actor, author end


//added by san on 4Aug06 start
function showMultiVal(ar,str, HLStr){
	var tmpStr = ""
	var tmpHL = ""
	var arHL = HLStr.split(",")
	//alert(arHL.length);

	if (str != "" && str != "||"){

		var arTmp = str.split("|")
		for (var i=0;i<arTmp.length;i++){

			//if (tmpStr != "") tmpStr = tmpStr + ", "
			for (var j=0;j<ar.length;j=j+2)
			{
				if (arTmp[i] == ar[j])
				{
					if (tmpStr != "") tmpStr = tmpStr + ", "
					tmpHL = ar[j + 1];
					for (var k=0; k<arHL.length; k++) {if (parseInt(arHL[k]) == parseInt(ar[j])) tmpHL="<b><font color=0066ff>" + ar[j+1] + "</font></b>"}
					tmpStr = tmpStr + tmpHL;break;
				}
			}

		}
	}

	if (tmpStr == "")
	{
		tmpStr = "尚未透露"
	}

	document.write(tmpStr)
}

//added by san on 4Aug06 end

function showMultiItem(str,ar){
	var tmpStr = ""
	if (str != "" && str !="||"){
		var arTmp = str.split("|")

		for (var i=1;i<arTmp.length-1;i++){
			//if (tmpStr != "") tmpStr = tmpStr + ", "
				for (var j=0;j<ar.length;j=j+2)
				{
					if (arTmp[i] == ar[j])
					{
					// Jasmin 2006/7/27 fix bug to display ","
					if (tmpStr != "") tmpStr = tmpStr + ", "
					tmpStr = tmpStr + ar[j+1];break;
					}
				}
		}
	}
	if (tmpStr == "")
	{
		tmpStr = "尚未透露"
	}

	document.write(tmpStr)
}

/*var arRetailTitle = new Array("","零售, 批發")
var arManufactureTitle = new Array("","製造業")
var arProfessionalTitle = new Array("","專業人仕")
var arGovernmentTitle = new Array("","政府部門")
var arTravelTitle = new Array("","酒店及旅遊")
var arBuildTitle = new Array("","建造, 裝修")
var arMediaTitle = new Array("","廣播/傳媒")
var arPublicTitle = new Array("","公共事務")
*/
function showOccupationTitle(val){
	var tmpStr = ""
	num = parseInt(val)
	if (num > 0)
	{
		if (num < 100)
		{
			tmpStr = arRetailTitle[1] + " - "

		}
		else if (num < 200)
		{
			tmpStr = arManufactureTitle[1] + " - "
		}
		else if (num < 300)
		{
			tmpStr = arProfessionalTitle[1] + " - "
		}
		else if (num < 400)
		{
			tmpStr = arGovernmentTitle[1] + " - "
		}
		else if (num < 500)
		{
			tmpStr = arTravelTitle[1] + " - "
		}
		else if (num < 600)
		{
			tmpStr = arBuildTitle[1] + " - "
		}
		else if (num < 700)
		{
			tmpStr = arMediaTitle[1] + " - "
		}
		else if (num < 800)
		{
			tmpStr = arPublicTitle[1] + " - "
		}
	}

	document.write(tmpStr)
}





function yearAddLstBoxYMD(name, prop, selYear){
	
	document.write("<select name='"+name+"' " + prop + " >")
	var dateobj = new Date();
	document.writeln('<option value="" '+ (selYear==''?' selected':'')+'>-Y-'); 
	curryear = dateobj.getYear();
	nextyear = dateobj.getYear() + 1;

	if (selYear != "" && selYear!=curryear && selYear!=nextyear)
	{	
		document.writeln("<option value=" + selYear + (selYear==selYear?' selected':'')+ ">" + selYear);
	}

	document.writeln("<option value=" + curryear + (selYear==curryear?' selected':'')+ ">" + curryear);
	document.writeln("<option value=" + nextyear + (selYear==nextyear?' selected':'')+ ">" + nextyear);
	document.write("</select>");
}

function changeYMD(f, _y, _m, _d) {
	
	var _theyear, _themonth, _theday;
	_theyear  = (_y.options[_y.selectedIndex].value!='')? _y.options[_y.selectedIndex].value : _y.options[1].value;
	_themonth = (_m.options[_m.selectedIndex].value!='')? _m.options[_m.selectedIndex].value : _m.options[1].value;
	_theday   = _d.selectedIndex;
	setMonthdayYMD(_theyear, _themonth, _theday,f, _y, _m, _d);
}

function setMonthdayYMD(theyear, themonth, theday,f, _y, _m, _d) {
	
	var monthday = new Array(31, (leapYear(theyear)? 29:28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	_d.options.length = themonth-1;
	theday = (theday > monthday[themonth-1])? monthday[themonth-1] : theday;
	_d.options[0] = new Option("-D-","");

	for(i=1;i<=monthday[themonth-1];i++) {
		eval("_d.options[i] = new Option(\"" + i + "\", \"" + ((i<10)?'0'+i:i) + "\", false, (theday==i)?true:false)");
	}
	_d.options[theday].selected = true;
}

function openWindow(url,name,w,h,pos,props){
	 var _wnd,left=0,top=0
	  if(name==null)name='wnd'
	 if(!pos||pos=='center'){left=screen.width?(screen.width-w)/2:100; top=screen.height?(screen.height-h)/2:100}
	 props='width='+w+',height='+h+',top='+top+',left='+left+(props==''?'':','+props)
	 _wnd=window.open(url,name,props)
	  if(pos=='maximize')_wnd.resizeTo(screen.availWidth,screen.availHeight)
	  if(name=='wnd'){wnd=_wnd}else{return _wnd}
}

function EP()
{
	openWindow('GetgiftMethod.asp','wndRP',650,400,'center','')
}

//************************************************************************************************************************
function initPhoto(num, arShowMembers, arPhotoPath, newRow, elementID)
{	
	var i
	var str = ""
	//alert (  arPhotoPath[0] );
	str = str+"<table border=0 cellspacing='8' cellpadding='2'><tr>";
	FirstPhoto = 0;
	for (i=0; i<=num-1; i=i+1)
	{
		if((typeof(arShowMembers[i]) != 'undefined') && (arShowMembers[i] != null))
		{
			str = str+"<td width=120 height=120 bgcolor=#EFEFEF align='center'><a href='/memberProfile.asp?idno="+arShowMembers[i]+"'><img src='http://f1.ecfriend.com/"+arPhotoPath[i]+"' border=0></a></td>"; // the function resizeImageHome resize width of the photo with consistent to height.
			LastPhoto = i;
		}
		if (newRow && (i==2)) //show the next 3 members in the new row
		{
			str = str+"</tr><tr>";
		}
	}
	str = str+"</tr></table>";
	//alert(str);
	document.getElementById(elementID).innerHTML = str; 

}

//This function shows the next 6 members when user pressed the "right arrow" icon of the table
function nextFunc(maxPageSize, PhotoPage, num, arShowMembers, arPhotoPath, newRow, elementID)
{
	var i
	var str = ""

	if (PhotoPage < maxPageSize-1) //show the next 6 members store in array
	{
		PhotoPage = PhotoPage + 1
	}
	else
	{
		PhotoPage = 0 //rotate to the first page 
	}
	//alert ("move right");


	str = str+"<table border=0 cellspacing='8' cellpadding='2'><tr>";
	for (i=0; i<=num-1; i=i+1)
	{
		str = str+"<td width=120 height=120 bgcolor=#EFEFEF align='center'><a href='/memberProfile.asp?idno="+arShowMembers[PhotoPage*num+i]+"'><img src='http://f1.ecfriend.com/"+arPhotoPath[PhotoPage*num+i]+"' border=0></a></td>";
		if (newRow && (i==2))
		{
			str = str+"</tr><tr>";
		}
	}
	str = str+"</tr></table>";
	//alert(str);
	document.getElementById(elementID).innerHTML = str; //replace the HTML code inside the DIV named "showPhoto"
	return PhotoPage;
}

//Display the previous 6 members when ckicked the "left arrow" icon of the spot table
function preFunc(maxPageSize, PhotoPage, num, arShowMembers, arPhotoPath, newRow, elementID)
{
	var i
	var str = ""

	if (PhotoPage > 0)
	{
		PhotoPage = PhotoPage - 1
	}
	else
	{
		PhotoPage = maxPageSize-1
	}

	str = str+"<table border=0 cellspacing='8' cellpadding='2'><tr>";
	for (i=0; i<=num-1; i=i+1)
	{
		str = str+"<td width=120 height=120 bgcolor=#EFEFEF align='center'><a href='/memberProfile.asp?idno="+arShowMembers[PhotoPage*num+i]+"'><img src='http://f1.ecfriend.com/"+arPhotoPath[PhotoPage*num+i]+"' border=0></a></td>";
		if (newRow && (i==2)) //next row to show members
		{
			str = str+"</tr><tr>";
		}
	}
	str = str+"</tr></table>";
	//alert(str);
	document.getElementById(elementID).innerHTML = str; //replace the HTML code inside the DIV named "showPhoto"
	return PhotoPage;
}

function preFunc_circular(maxPageSize, PageSize, arShowMembers, arPhotoPath, newRow, elementID)
{
	var i
	var count = 0
	var str = ""
	//alert('FirstPhoto:'+FirstPhoto+'  LastPhoto:'+LastPhoto + '  PageSize:'+PageSize);

	//Find out the last index of photo in the array "arShowMembers" that have data to show
	LastPhoto = FirstPhoto - 1
	if (LastPhoto < 0) //if equal to the start index of array
	{
		LastPhoto = maxPageSize * PageSize - 1 //goto the last index of array
		while (((typeof(arShowMembers[LastPhoto]) == 'undefined') || (arShowMembers[LastPhoto] == null))&&(LastPhoto >= 0))
		{
			LastPhoto -- ; //if the index does not contain any data to show, find the previous index
			//alert ('LastPhoto:'+LastPhoto);
		}
	}
	//alert ('LastPhoto:'+LastPhoto);
	i = LastPhoto;
	while ((count<PageSize) && i>=0) //find the first photo
	{
		i--;
		count++;
		if (count==PageSize)
		{
			FirstPhoto = LastPhoto - PageSize + 1;
		}
		else 
		{
			if (i==0) 
			{
				FirstPhoto = 0;
			}
		}
	}
	
	//Find out the first index of photo in the array "arShowMembers" if it cannot found before

	if (count < 5) //if equal to start of array
	{
		FirstPhoto = maxPageSize * PageSize - 1 //goto the last index of array
		while (((typeof(arShowMembers[FirstPhoto]) == 'undefined') || (arShowMembers[FirstPhoto] == null)||(count < PageSize)) && (FirstPhoto >= 0))
		{
			if ((typeof(arShowMembers[FirstPhoto]) != 'undefined') && (arShowMembers[FirstPhoto] != null))
			{
				count++;
			}	
			if ((count < PageSize))
			{
				FirstPhoto --;
			}
		}
	}
	//alert ('FirstPhoto:'+FirstPhoto);

	//show the photos starting from index equal to FirstPhoto
	str = str+"<table border=0 cellspacing='8' cellpadding='2'><tr>";
	i = FirstPhoto;
	do
	{ 
		if((typeof(arShowMembers[i]) != 'undefined') && (arShowMembers[i] != null))
		{
			str = str+"<td width=120 height=120 bgcolor=#EFEFEF align='center'><a href='/memberProfile.asp?idno="+arShowMembers[i]+"'><img src='http://f1.ecfriend.com/"+arPhotoPath[i]+"' border=0></a></td>";
			if (newRow && (i==2)) //next row to show members
			{
				str = str+"</tr><tr>";
			}
		}
		i++;
	}
	while ((i-1!=LastPhoto)&&(i-1<=(maxPageSize * PageSize - 1))); //stop is lastPhoto was shows or reached the index at the end of array
	
	//if have some photo left
	if (i-1 != LastPhoto)
	{
		i = 0; //show the photos from start of array
		do
		{
			str = str+"<td width=120 height=120 bgcolor=#EFEFEF align='center'><a href='/memberProfile.asp?idno="+arShowMembers[i]+"'><img src='http://f1.ecfriend.com/"+arPhotoPath[i]+"' border=0></a></td>";
			if (newRow && (i==2)) //next row to show members
			{
				str = str+"</tr><tr>";
			}
			i++;
			//alert(i-1!=LastPhoto);
		}
		while (i-1!=LastPhoto);
	}

	str = str+"</tr></table>";
	//alert(str);
	document.getElementById(elementID).innerHTML = str; //replace the HTML code inside the DIV named "showPhoto"

}

function nextFunc_circular(maxPageSize, PageSize, arShowMembers, arPhotoPath, newRow, elementID)
{
	var i;
	var count = 0;
	var str = "";
	var flag;
	//alert('FirstPhoto:'+FirstPhoto+'  LastPhoto:'+LastPhoto + '  PageSize:'+PageSize);

	//Find out the last index of photo in the array "arShowMembers" that have data to show
	flag = FirstPhoto;
	FirstPhoto = LastPhoto + 1
	while ((FirstPhoto != flag)&&((typeof(arShowMembers[FirstPhoto]) == 'undefined')||(arShowMembers[FirstPhoto] == null))) //if equal to the start index of array
	{
		FirstPhoto ++ ; //if the index does not contain any data to show, find the previous index
		if (FirstPhoto > maxPageSize * PageSize - 1)
		{
			FirstPhoto = 0 //goto the last index of array
		}
		
			//alert ('LastPhoto:'+LastPhoto);
	}
	//alert ('FirstPhoto:'+FirstPhoto);

	str = str+"<table border=0 cellspacing='8' cellpadding='2'><tr>";
	i = FirstPhoto;

	//show the photos starting from index equal to FirstPhoto
	do
	{
		if((typeof(arShowMembers[i]) != 'undefined') && (arShowMembers[i] != null))
		{
			str = str+"<td width=120 height=120 bgcolor=#EFEFEF align='center'><a href='/memberProfile.asp?idno="+arShowMembers[i]+"'><img src='http://f1.ecfriend.com/"+arPhotoPath[i]+"' border=0></a></td>";
			count++;
			LastPhoto = i;
			//alert ('LastPhoto:'+ LastPhoto);
			if (newRow && (i==2)) //next row to show members
			{
				str = str+"</tr><tr>";
			}
		}
		i++;
	}
	while ((i<=(maxPageSize * PageSize - 1))&& (count < PageSize)); //stop is lastPhoto was shows or reached the index at the end of array
	
	//if have some photo left
	if (count < PageSize)
	{
		i = 0; //show the photos from start of array
		while ((count < PageSize)&&(i != FirstPhoto))
		{
			count++;
			if((typeof(arShowMembers[i]) != 'undefined') && (arShowMembers[i] != null))
			{
				LastPhoto = i;
				str = str+"<td width=120 height=120 bgcolor=#EFEFEF align='center'><a href='/memberProfile.asp?idno="+arShowMembers[i]+"'><img src='http://f1.ecfriend.com/"+arPhotoPath[i]+"' border=0></a></td>";
				if (newRow && (i==2)) //next row to show members
				{
					str = str+"</tr><tr>";
				}
				i++;
			}
			//alert('count:'+count);
		}

	}

	str = str+"</tr></table>";
	//alert(str);
	document.getElementById(elementID).innerHTML = str; //replace the HTML code inside the DIV named "showPhoto"

}