var left_banner = new Array();
var imagelocation = '../AD/';

String.prototype.endsWith = function(str)
{return (this.match(str+"$")==str)}

/* For the left banner (under the menu) */
function left_getURLParam(){
	var strHref = window.location.href;
	var getURLink = new Array();
	var URL = '';
	var last1 = '';
	var last2 = '';
	var c = 0;
	
	last1 = strHref.lastIndexOf('_')-1;
	last2 = strHref.lastIndexOf('/')+1;

	if (last1 == -2){
		last1 = strHref.lastIndexOf('.')-1;
	}

	for(c = last2; c <= last1; c++){
		URL = URL + strHref.charAt(c);	
	}
	
	if (URL == 'index'){

		/* modified here for index page */

		left_banner = [
		//["adtop01.gif","http://www.citylifehk.com/citylife/pdf/dis_coupon.pdf"]
		//,["../AD/SeaLagoon_0808.swf","", 160, 160]
		//,["ad03.gif","http://www.davidfashions.com.hk/"]
		];		
	}
	else
	if (URL == 'cover'){

		/* modified here for the cover page */

		left_banner = [
		//["ad01.gif","http://www.citylifehk.com/citylife/pdf/dis_coupon.pdf"]
		//,["ad02.gif","http://www.iatolife.com/"]
		//,["ad03.gif","http://www.davidfashions.com.hk/"]
		];		
	}
	else
	if (URL == 'hottable'){

		/* modified here for the page of hottable */

		left_banner = [
		//["ad01.gif","http://www.citylifehk.com/citylife/pdf/dis_coupon.pdf"]
		//,["ad02.gif","http://www.iatolife.com/"]
		//,["ad03.gif","http://www.davidfashions.com.hk/"]
		];		
	}
	else
	if (URL == 'shopping'){

		/* modified here for the page of shopping */

		left_banner = [
		//["ad01.gif","http://www.citylifehk.com/citylife/pdf/dis_coupon.pdf"]
		//,["ad02.gif","http://www.iatolife.com/"]
		//,["ad03.gif","http://www.davidfashions.com.hk/"]
		];		
	}
	else
	if (URL == 'well_being_feature'){

		/* modified here for the page of well_being_feature */

		left_banner = [
		//["ad01.gif","http://www.citylifehk.com/citylife/pdf/dis_coupon.pdf"]
		//,["ad02.gif","http://www.iatolife.com/"]
		//,["ad03.gif","http://www.davidfashions.com.hk/"]
		];		
	}
	else
	if (URL == 'unusual'){

		/* modified here for the page of unusual */

		left_banner = [
		//["ad01.gif","http://www.citylifehk.com/citylife/pdf/dis_coupon.pdf"]
		//,["ad02.gif","http://www.iatolife.com/"]
		//,["ad03.gif","http://www.davidfashions.com.hk/"]
		];		
	}
	else
	if (URL == 'history'){

		/* modified here for the page of history */

		left_banner = [
		//["ad01.gif","http://www.citylifehk.com/citylife/pdf/dis_coupon.pdf"]
		//,["ad02.gif","http://www.iatolife.com/"]
		//,["ad03.gif","http://www.davidfashions.com.hk/"]
		];		
	}
	else {

		/* modified here for the other pages except above */
		
		left_banner = [
		//["ad01.gif","http://www.citylifehk.com/citylife/pdf/dis_coupon.pdf"]
		//,["ad02.gif","http://www.iatolife.com/"]
		//,["ad03.gif","http://www.davidfashions.com.hk/"]
		//,["ad04.gif","http://www.davidfashions.com.hk/"]
		];		
	}
}
 

function left_output(){
	var outputstring = '';
	if (left_banner.length > 0){	
		for (x=0; x < left_banner.length; x++){

			if(left_banner[x][0].endsWith(".swf")){
				outputstring += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+left_banner[x][2]+"\" height=\""+left_banner[x][3]+"\">"+
						"<param name=\"movie\" value=\""+imagelocation+left_banner[x][0]+"\" />"+
						"<param name=\"quality\" value=\"high\" />"+
						"<embed src=\""+imagelocation+left_banner[x][0]+"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+left_banner[x][2]+"\" height=\""+left_banner[x][3]+"\"></embed>"+
						"</object>";
			}
			else{
				outputstring += "<a id=\"left_adlink"+x+"\" name=\"left_adlink"+x+"\" href=\"\" target=\"_blank\"><img id=\"left_ad"+x+"\" name=\"left_ad"+x+"\" src=\"\" vspace=\"5\" border=\"0\" width=\"160\" /></a>";
			}		
			
		//outputstring = '<a id=\"left_adlink'+x+'\" name=\"left_adlink'+x+'\" href=\"\" target=\"_blank\"><img id=\"left_ad'+x+'\" name=\"left_ad'+x+'\" src=\"\" vspace=\"5\" border=\"0\" width=\"160\" /></a>';
		//document.write(outputstring);
		}

		document.getElementById('left_adrotatediv').innerHTML = outputstring;
	}
}

function left_bannerFun(){ 
	
	/* do not modify code below */	
	var number = left_banner.length;		
	var source = ''
	
	var i = 0;
	var count = 0;
	var output = new Array();
	var outL = new Array();

	var j = 0;
	var outImage, imgLoc, outLink;

	for (j = 0; j < left_banner.length; j++){
		outImage = imagelocation + left_banner[j][0];
		outLink = left_banner[j][1];
		imgLoc = "left_ad" + j;
		linkLoc = "left_adlink" + j;
		if(outImage.endsWith(".swf")){
		}
		else{
			document.getElementById(imgLoc).src = outImage;
			document.getElementById(linkLoc).href = outLink;
		}
	}
}



