var tempHtml;
var tempStr1;
var tempStr2;
var tempStr3;
if (section == null)	var section = 0;
if (level1 == null)	var level1 = "";
if (level2 == null)	var level2 = "";
if (level3 == null)	var level3 = "";
if (selectArray == null)	var selectArray = null;
var id1 = null;
var id2 = null;
var id3 = null;

getLevel();
genId();


function getLevel() {
	var link = location.href.toString();
	var obj = sectionArray[section];
	
	if (level1 == "") {
		for (var i=0; i<obj.length; i++) {
			if (link.indexOf(("/" + obj[i].id + "/")) > -1) {
				level1 = obj[i].id;
				
				if (level2 == "" && obj[i].subSection) {
					var obj1 = obj[i].subSection;
					
					for (var j=0; j<obj1.length; j++) {
						if (link.indexOf((obj1[j].id)) > -1) {
							level2 = obj1[j].id;
							
							if (level3 == "" && obj1[j].subSection) {
								var obj2 = obj1[j].subSection;
								
								for (var k=0; k<obj2.length; k++) {
									if (link.indexOf((obj2[k].id)) > -1) {
										level3 = obj2[k].id;
										
										break;
									}
								}
							} else {
								break;
							}
						}
					}
				} else {
					break;
				}
			}
		}
	}	
	
//	alert("level2: "+level2);
}


function genId() {	
	var obj = sectionArray[section];
	
	if (level1 != "") {
		for (var i=0; i<obj.length; i++) {
			//alert(obj[i].id + "  " + level1);
			if (obj[i].id == level1) {
				id1 = i;
				
				if (level2 != "") {
					var obj1 = obj[i].subSection;
					for (var j=0; j<obj1.length; j++) {
						//alert(obj[i].id + "  " + level1);
						if (obj1[j].id == level2) {
							id2 = j;
							
							if (level3 != "") {
								var obj2 = obj1[j].subSection;
								for (var k=0; k<obj2.length; k++) {
									//alert(obj[i].id + "  " + level1);
									if (obj2[k].id == level3) {
										id3 = k;
										break;
									}
								}
							} else {
								break;
							}
						}
					}
				} else {
					break;
				}
			}
		}
	}
//alert("id1: "+id1+"   id2: "+id2+"   id3: "+id3);
}


function genTop() {
	
	tempHtml = '';
tempHtml += '<div id="header">'
tempHtml += '		<a id="top" name="top"></a>'
tempHtml += '		<div id="logo">'
tempHtml += '			<a href="http://www.cpp.co.uk/" target="_blank"><img src="' + path + 'images/cppipp.gif" alt="CPP Identity Protection Alert" width="340" height="39" border="0"/></a>'
tempHtml += '		</div>'
tempHtml += '		<table border="0" cellpadding="0" cellspacing="0" align="right">'
tempHtml += '		<tr><td><img src="' + path + 'images/common/spacer.gif" height="40" width="1" /></td></tr>		'
tempHtml += '		<tr>'
tempHtml += '			<td align="left"><img src="' + path + 'images/common/spacer.gif" width="1" height="20" border="0" /></td>'
tempHtml += '		</tr>'
tempHtml += '		</table>'
tempHtml += '		</div>'
	document.write(tempHtml);
	
}

function genNav(section) {
	// JavaScript Document
	tempHtml = '';
	if(!section)
	var sect = 1;
	else
	var sect = section;
	var obj = sectionArray[sect];
	var temp = "";
	
tempHtml += "<div id=\"newCppNav\">";
tempHtml += "				<ul>";

if(sect==1) {
tempHtml += "					<li style=\"border-top: 1px dashed #999999;\"><a class=\"activeNavTopLevel\" href=\"" + path + "index.htm\" title=\"CPP Hong Kong Home\">CPP Hong Kong Home</a></li>";
tempHtml += "					<li>&nbsp;</li>";
}
if(sect==2) {
tempHtml += "					<li style=\"border-top: 1px dashed #999999;\"><a class=\"activeNavTopLevel\" href=\"" + path + "customers/card_pro.htm\" title=\"Card Protection Select\">Card Protection Select</a></li>";
tempHtml += "					<li>&nbsp;</li>";
}
if(sect==3) {
tempHtml += "					<li style=\"border-top: 1px dashed #999999;\"><a class=\"activeNavTopLevel\" href=\"" + path + "customers/card_assist.htm\" title=\"Card Assist\">Card Assist</a></li>";
tempHtml += "					<li>&nbsp;</li>";
}
		for (var i=0; i<obj.length; i++) {
			if(level1==obj[i].id) {
				if(obj[i].subSection)
				temp = "class=\"activeNavFirstLevel\"";
				else
				temp = "class=\"activeNavThirdLevel\"";
			}
			else
			temp = "";
			
			tempHtml += "<li><a href=\"" + path + obj[i].link + "\" title=\"" + obj[i].name + "\" " + temp + ">" + obj[i].name + "</a></li>"
			
			if(temp!="" && obj[i].subSection) {
				var obj1 = obj[i].subSection;
				var temp2 = "";
				
				
				for (var j=0; j<obj1.length; j++) {
				
					if(level2==obj1[j].id) {
						if(obj1[j].subSection) {
							temp = "class=\"activeNavSecondLevelIn\"";
							temp2 = "class=\"activeNavSecondLevel\"";
						} else {
							temp = "class=\"activeNavSecondLevelOut\"";
							temp2 = "class=\"activeNavThirdLevel\"";
						}						
					}
					else {
					temp = "class=\"activeNavSecondLevelOut\"";
					temp2 = "";
					}
				
					tempHtml += "<li " + temp + "><a " + temp2 + " href=\"" + path + obj1[j].link + "\" title=\"" + obj1[j].name + "\">" + obj1[j].name + "</a></li>"
					
					if(temp2=="class=\"activeNavSecondLevel\"") {
						var obj2 = obj1[j].subSection;
						temp = "class=\"activeNavThirdLevel\"";
						
						for (var k=0; k<obj2.length; k++) {
						
							if(level3==obj2[k].id) {
								temp2 = " class=\"activeNavThirdLevel\"";
							} else
							temp2 = "";
						
							tempHtml += "<li " + temp + "><a" + temp2 + " href=\"" + path + obj2[k].link + "\" title=\"" + obj2[k].name + "\">" + obj2[k].name + "</a></li>";
						}
						
					}
					
				}
				
			}
		}
		
tempHtml += "<li>&nbsp;</li>";
tempHtml += "<li><a href=\"javascript:changeLanguage('chi');\"><span class=\"menuChi\">&#20013;&#25991;</span></a></li>";
tempHtml += "					</ul>";

tempHtml += "			</div>";

/*
if(sect==1) {
	
tempHtml += "<div id=\"buyOnline\">";
tempHtml += "		<br /><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" style=\"font-size: 10px\">";
tempHtml += "				<tr bgcolor=\"#FF0000\" style=\"color:#FFFFFF\">";
tempHtml += "				<td style=\"border-bottom: #333333 1px solid; padding: 5px 5px 5px 5px\"><strong>EXISTING CUSTOMERS</strong></td>";
tempHtml += "				</tr>";
tempHtml += "				<tr bgcolor=\"#EEEEEE\" style=\"color:#666666\">";
tempHtml += "				<td style=\"padding: 5px 5px 5px 5px\">A quick reference guide on some of the key services available to you.<br><br>For Card Assist customers <a href=\"javascript:NewWindow(path+'customers/card_pro.htm', 'member', '793', '600', 'yes', 'no');\">&lt;Click here&gt;</a><br>For Card Protection customers <a href=\"javascript:NewWindow(path+'customers/card_assist.htm', 'member', '793', '600', 'yes', 'no');\">&lt;Click here&gt;</a></td>";
tempHtml += "				</tr></table>";

tempHtml += "			</div>";

}
*/
/*
tempHtml += "					<li><a href=\"http://www.cpp.co.uk/login.html\" title=\"Login\">Login</a></li>"
tempHtml += "					<li><a href=\"http://www.cpp.co.uk/aboutus.html\" title=\"About CPP\">About CPP</a></li>"
tempHtml += "					<li><a class=\"activeNavFirstLevel\" href=\"#\" title=\"Our products\">Our products</a></li>"
tempHtml += "					<li class=\"activeNavSecondLevelOut\"><a href=\"http://www.cpp.co.uk/cardprotection/\" title=\"Card Protection Select\">Card Protection Select</a></li>"
tempHtml += "					<li class=\"activeNavSecondLevelIn\"><a class=\"activeNavSecondLevel\" href=\"index.html\" title=\"Identity Protection\">Identity Protection</a></li>"
tempHtml += "					<li class=\"activeNavThirdLevel\"><a href=\"benefits.html\" title=\"Why choose Identity Protection\">Why choose Identity Protection?</a></li>"
tempHtml += "					<li class=\"activeNavThirdLevel\"><a href=\"learnmore.html\" title=\"What is Identity Fraud?\">What is Identity Fraud?</a></li>"
tempHtml += "                    <li class=\"activeNavThirdLevel\"><a href=\"partners.html\" title=\"Our partners\">Our partners</a></li>"
tempHtml += "        			<li class=\"activeNavThirdLevel\"><a href=\"#\" onclick=\"javascript:launchRiskAssessment(return false;\" class=\"redLink\" title=\"Take our ID risk test\">Online risk assessment</a></li>"
tempHtml += "				  	<li class=\"activeNavThirdLevel\"><a href=\"casestudies.html\" title=\"Case studies\">Case studies</a></li>"
tempHtml += "					<li class=\"activeNavThirdLevel\"><a href=\"faq.html\" title=\"Questions and Answers\">Questions and Answers</a></li>"
tempHtml += "					<li class=\"activeNavThirdLevel\"><a href=\"membersarealogin.html\" title=\"Members Area Login\">Members Area Login</a></li>"
tempHtml += "					<li class=\"activeNavThirdLevel\"><a href=\"usefullinks.html\" title=\"Useful links\">Useful links</a></li>"
tempHtml += "					<li class=\"activeNavThirdLevel\"><a href=\"howtobuy.html\" title=\"How to buy\">How to buy</a></li>"
tempHtml += "					<li class=\"activeNavSecondLevelOut\"><a href=\"http://www.cpp.co.uk/phonesafe\" title=\"Phonesafe\">Phonesafe</a></li>"
tempHtml += "					<li class=\"activeNavSecondLevelOut\"><a href=\"http://www.cpp.co.uk/dogtag\" title=\"Phonesafe\">Dogtag Travel</a></li>"
tempHtml += "					<li><a href=\"http://www.cpp.co.uk/talktous.html\" title=\"Talk to us\">Talk to us</a></li>"
tempHtml += "					<li><a href=\"http://www.cppgroupplc.com/\" title=\"CPP Corporate\">CPP Corporate</a></li>"
*/

	document.write(tempHtml);
}

function genRightCol() {
var temphtml="";

temphtml += '<div class="rightcol" >';
temphtml += '<div id="right_nav_border">';
temphtml += '<p>MEMBERS AREA LOGIN</p>';
temphtml += '<a href="#" class="loginHome">LOGIN</a>';
temphtml += '</div>';
temphtml += '<div class="right_nav_boarder">';
temphtml += '  <div class="partner_links">In association with</div>';
temphtml += '</div>';
temphtml += '<div class="right_nav_spacer" style="margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;"><a href="#" class="redLink" title="Helpful advice"><img src="../images/garlik.jpg" alt="garlik" border="0" style="border: none;" /></a></div>';
temphtml += '<div class="right_nav_spacer" style="margin: 0px 0px 0px 0px; padding: 0px 0px 5px 0px;"><a href="#" class="redLink" title="Helpful advice"><img src="../images/experian.jpg" alt="experian" border="0" style="border: none;" /></a></div>';

temphtml += '<div class="right_nav_spacer" style="border-top: 1px dashed #999999;text-align: center: margin: 0px 0px 0px 0px; padding: 10px 0px 0px 0px;"><a href="#" onclick="javascript:launchRiskAssessment();return false;" class="redLink" title="Take our ID risk test"><img src="../images/id_test.jpg" alt="Take our ID risk test" width="135" height="97" border="0" style="border: none;" /></a></div>';
temphtml += '<div class="right_nav_spacer" style="text-align: center: margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;"><a href="benefits.html" class="redLink" title="Helpful advice"><img src="../images/help_advice.jpg" alt="Helpful advice" border="0" style="border: none;" /></a></div>';
temphtml += '<div class="right_nav_spacer" style="text-align: center: margin: 0px 0px 0px 0px; padding: 0px 0px 0px 0px;"><a href="howToBuy.html" class="redLink" title="Call us today"><img src="../images/contact_us.jpg" alt="Call us today" width="135" height="85" style="border: none;" /></a></div>';

temphtml += '</div>';

document.write(temphtml);
}

function genFooter() {
	
	tempHtml = ''
	tempHtml += ' 	<div id="footer" valign="bottom">'
	tempHtml += '		<a href="http://www.cppasia.com/" target="_blank">CPP Asia</a> &#8226;'
	tempHtml += '		<a href="#" onclick="javascript:printPopup(\''+ path +'doc/terms.pdf\');return false;" title="Legal">Terms of Use</a> &#8226;'
	tempHtml += '		<a href="#" onclick="javascript:printPopup(\''+ path +'doc/privacy.pdf\');return false;" title="Privacy">Privacy Policy</a> &#8226;'
	tempHtml += '		<a href="#" onclick="relocateWindow(\'/index.html\',1);return false;" title="CPP group" >CPP Group</a> &#8226; &copy; 2008-2010 CPP | <a href="'+path+'others/sitemap.htm">Sitemap</a><br />'
	tempHtml += '  <br /><small>Last Updated Jan. 2010</small><br /></div>'
	document.write(tempHtml);
}


function genMemTop() {
	tempHtml = '';
	tempHtml += '<table width="780" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '<tr valign="top">';
	tempHtml += '	<td style="padding:17px 0px 14px 20px;"><img src="'+path+'images/member/logo.gif" width="318" height="28" border="0"></td>';
	tempHtml += '	<td width="140" style="padding:0px 10px 0px 0px;" align="right">';
	tempHtml += '		<table width="140" border="0" cellspacing="0" cellpadding="0" bgcolor="#E6E7E8" height="20">';
	tempHtml += '			<tr valign="top">';
	tempHtml += '				<td width="28" align="center" class="close"><a href="javascript:window.close();" class="close">x</a></td>';
	tempHtml += '				<td class="close"><a href="javascript:window.close();" class="close">Close this window</a></td>';
	tempHtml += '			</tr>';
	tempHtml += '		</table>';
	tempHtml += '	</td>';
	tempHtml += '</tr>';
	tempHtml += '</table>';
	
	document.write(tempHtml);
}


function genMemNav() {
	var sect = 2;
	var obj = sectionArray[sect];
	
	tempHtml = '';
	tempHtml += '	<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '			<tr>';
	tempHtml += '				<td style="padding:20px 0px 20px 0px;">';
	tempHtml += '					<table width="100%" border="0" cellspacing="0" cellpadding="0">';
	tempHtml += '						<tr>';
	tempHtml += '							<td style="background:url('+path+'images/common/dash.gif) repeat-x;"><img src="'+path+'images/common/spacer.gif" width="1" height="1"></td>';
	tempHtml += '						</tr>';
	for (var i=0; i<obj.length; i++) {
		if (id1 == i) {
			tempStr1 = 'On';
			tempStr3 = '<img src="'+path+'images/common/mem_arrow.gif" align="absmiddle">';
			var isSect = 1;
		} else {
			tempStr1 = 'Off';
			tempStr3 = '';
			var isSect = 0;
		}
		
		
		tempHtml += '<tr>';
		tempHtml += '	<td style="padding:5px 20px 5px 20px;">'+tempStr3+' <a href="'+genLink(obj[i].link)+'" target="'+obj[i].target+'" class="memNav'+tempStr1+'">'+obj[i].name+'</a></td>';
		tempHtml += '</tr>';
		
		tempHtml += '<tr>';
		tempHtml += '	<td style="background:url('+path+'images/common/dash.gif) repeat-x;"><img src="'+path+'images/common/spacer.gif" width="1" height="1"></td>';
		tempHtml += '</tr>';
		
		
		tempHtml += '<tr>';
		tempHtml += '<td>';
		tempHtml += '	<table width="100%" border="0" cellspacing="0" cellpadding="0">';
		
		
		if (obj[i].subSection && id1 == i) {
			var obj1 = obj[i].subSection;
			
		tempHtml += '<tr>';
		tempHtml += '<td colspan="2"><img src="'+path+'images/common/spacer.gif" width="1" height="5"></td>';
		tempHtml += '</tr>';
			for (var j=0; j<obj1.length; j++) {
				if (id1 == i && id2 == j) {
					tempStr1 = 'On';
					var isSect1 = 1;
				} else {
					tempStr1 = 'Off';
					var isSect1 = 0;
				}
				
				tempHtml += '<tr valign="top"><td width="10" style="padding:0px 0px 5px 20px;" class="memNavOff">-</td><td style="padding:2px 0px 5px 0px;"><a href="'+genLink(obj1[j].link)+'" target="'+obj1[j].target+'" class="memNav'+tempStr1+'">'+obj1[j].name+'</a></td></tr>';
				
				MM_preloadImages(path+'images/common/btn_'+obj1[j].id+'_f2.gif');
			}
				
				tempHtml += '<tr>';
				tempHtml += '	<td colspan="2" style="background:url('+path+'images/common/dash.gif) repeat-x;"><img src="'+path+'images/common/spacer.gif" width="1" height="1"></td>';
				tempHtml += '</tr>';
		}
		tempHtml += '</table>';
		tempHtml += '</td>';
		tempHtml += '</tr>';
		
		MM_preloadImages(path+'images/common/btn_'+obj[i].id+'_f2.gif');
	}
	
	tempHtml += '					</table>';
	tempHtml += '				</td>';
	tempHtml += '			</tr>';
	tempHtml += '			<tr>';
	tempHtml += '				<td><img src="'+path+'images/member/banner_'+level1+'_'+level2+'.jpg" width="129" height="254"></td>';
	tempHtml += '			</tr>';
	tempHtml += '		</table>';
	
	document.write(tempHtml);
}

function genMemLogin() {
	
	tempHtml = '';
	tempHtml += '	<table width="150" border="0" cellspacing="0" cellpadding="0" height="190">';
	tempHtml += '			<tr bgcolor="#ED1C24">';
	tempHtml += '				<td style="background:url('+path+'images/common/member_t_r.gif) no-repeat top right; background-color:#ED1C24;"><img src="'+path+'images/common/member_t_l.gif" width="8" height="8"></td>';
	tempHtml += '			</tr>';
	tempHtml += '			<tr>';
	tempHtml += '				<td valign="top" bgcolor="#ED1C24" style="padding:12px 10px 2px 10px;" height="100%">';
	tempHtml += '	<form action="'+arguments[1]+'.jsp" method="post" name="loginForm">';
	tempHtml += '					<table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%">';
	tempHtml += '						<tr valign="top">';
	tempHtml += '							<td height="11" class="white" style="background:url('+path+'images/common/dash_white.gif) repeat-x bottom center; padding:0px 0px 10px 0px;" colspan="2">MEMBERS AREA LOGIN</td>';
	tempHtml += '						</tr>';
	tempHtml += '						<tr valign="top">';
	tempHtml += '							<td class="white" style="padding:10px 0px 0px 0px;"><input name="loginPsw" type="password" class="inputMem"></td>';
	tempHtml += '							<td class="white" style="padding:10px 0px 0px 0px;"><a href="javascript:document.loginForm.submit();" class="white">GO</a></td>';
	tempHtml += '						</tr>';
	if( arguments[0] )
	{
		tempHtml += '						<tr valign="top">';
		tempHtml += '							<td class="white" style="padding:0px 0px 10px 0px;" colspan="2"><span class="white">INCORRECT PASSWORD</span></td>';
		tempHtml += '						</tr>';
	}
	tempHtml += '						<tr valign="top">';
	tempHtml += '							<td height="11" class="white" style="padding:0px 0px 10px 0px;" colspan="2"><a href="javascript:NewWindow(\''+path+'general/contact.jsp\', \'member\', \'200\', \'100\', \'no\', \'no\');" class="white">FORGOTTEN PASSWORD</a></td>';
	tempHtml += '						</tr>';
	tempHtml += '					</table>';
	tempHtml += '		</form>';
	tempHtml += '				</td>';
	tempHtml += '			</tr>';
	tempHtml += '			<tr bgcolor="#ED1C24">';
	tempHtml += '				<td style="background:url('+path+'images/common/member_b_r.gif) no-repeat top right; background-color:#ED1C24;"><img src="'+path+'images/common/member_b_l.gif" width="8" height="8"></td>';
	tempHtml += '			</tr>';
	tempHtml += '		</table>';
	
	document.write(tempHtml);
}

function genMemFooter(pad) {
	tempHtml = '';
	
	if (pad) {
		var str = pad;
	} else {
		var str = 0;
	}
	
	tempHtml += '<table width="780" border="0" cellspacing="0" cellpadding="0" height="47">';
	
	tempHtml += '<tr>';
	tempHtml += '	<td style="padding:0px 0px 0px 20px;"><img src="'+path+'images/member/title_footer.gif" alt="It&rsquo;s YOUR identity" width="175" height="21"></td>';
	tempHtml += '	<td align="right" valign="bottom" class="footer" style="padding:0px 10px 5px 0px;">Copyright &copy; 2007 Card Protection Plan Ltd. All right reserved.</td>';
	tempHtml += '	</td>';
	tempHtml += '</tr>';
	
	tempHtml += '</table>';
	
	document.write(tempHtml);
}


function genLink(i) {
	if ((i.indexOf('javascript') > -1) | (i.indexOf('http') > -1)) {
		var link = i;
	} else {
		var link = path + i;
	}
	
	return link;
}


function genTitle(pad) {
	var obj = sectionArray[section][id1];
	tempHtml = '';
	
	if (pad) {
		var str = pad;
	} else {
		var str = 20;
	}
	
	tempHtml += '<table width="100%" border="0" cellspacing="0" cellpadding="0" id="footer">';
	
	tempHtml += '<tr>';
	tempHtml += '	<td style="padding:0px 0px '+str+'px 0px;"><img src="'+path+'images/'+obj.id+'/title.gif" alt="'+obj.name+'"></td>';
	tempHtml += '</tr>';
	
	tempHtml += '</table>';
	
	document.write(tempHtml);
}

