function init()
{
	var url = '../xml/'+getTree()[0]+'.xml';
	ajaxLoader(url, shopPaser);

}

function GetParam(name)
{
	var start=location.search.indexOf("?"+name+"=");
	if (start<0) start=location.search.indexOf("&"+name+"=");
 	if (start<0) return '';
 	start += name.length+2;
 	var end=location.search.indexOf("&",start)-1;
 	if (end<0) end=location.search.length;
 	var result=location.search.substring(start,end);
 	var result='';
 	for(var i=start;i<=end;i++)
 	{
 		var c=location.search.charAt(i);
 		result=result+(c=='+'?' ':c);
 	}
 	//alert(unescape(result));
 	return unescape(result);
}

function genShopDetail(shop)
{
	var id = shop.id;
	var name = shop.name;
	var hour = shop.hour;
	var tel = shop.tel;
	var loc = shop.loc;
	var desc = shop.desc;
	var galleries = new Object();

	//newDiv.innerHTML = "abc";
	var clearer = document.createElement('BR');
	clearer.setAttribute("class", 'clearer');
	clearer.className = 'clearer';
	//create shop logo
	// var shop_logo_img = document.createElement('IMG');
	// shop_logo_img.setAttribute("src",'../images/'+getTree()[0]+'/logo/'+id+'.gif');
	// shop_logo_img.setAttribute("alt", id);
	// if (id == 'sujika')
		// {
			// shop_logo_img.setAttribute("width", '113px');
			// shop_logo_img.setAttribute("height", '79px');
			// shop_logo_img.setAttribute("style", 'width:79px;height:79px;');
		// }

	//create shop div
	var shop_logo_div = document.createElement('DIV');
	shop_logo_div.setAttribute("id","shop_logo");
	shop_logo_div.innerHTML = '<img src="../images/'+getTree()[0]+'/logo/'+id+'.gif" alt="'+id+'"/>'
	//shop_logo_div.appendChild(shop_logo_img);

			
	//shop name
	// <span class="title">Name :</span> '+name+'<br />
	//var shop_name_txt = document.createTextNode(name);
	var shop_name_txt= document.createElement('SPAN');
	shop_name_txt.innerHTML = name;
	var shop_name = document.createElement('SPAN');
	shop_name.setAttribute("class", 'title');
	shop_name.className = 'title';
	shop_name.innerHTML = 'Name : ';

	//shop open hours
	// <span class="title">Open Hours :</span> '+hour
	//var shop_hour_txt = document.createTextNode(hour);
	var shop_hour_holder = document.createElement('SPAN');
	
	var shop_hour_txt= document.createElement('SPAN');
	shop_hour_txt.innerHTML = hour;
	var shop_hour= document.createElement('SPAN');
	shop_hour.setAttribute("class", 'title');
	shop_hour.className = 'title';
	shop_hour.innerHTML = 'Business Hours : ';
	
	//shop_hour_holder.appendChild(shop_hour);
	//shop_hour_holder.appendChild(shop_hour_txt);

	// var shop_hour_table_tr = document.createElement('tr');
	// var shop_hour_table_td_left = document.createElement('td');
	// var shop_hour_table_td_right = document.createElement('td');
	// var shop_hour_table = document.createElement('TABLE');
		
	// shop_hour_table_tr.appendChild(shop_hour_table_td_left);
	// shop_hour_table_tr.appendChild(shop_hour_table_td_right);
	// shop_hour_table.appendChild(shop_hour_table_tr);
	
	//shop_hour_holder.appendChild(shop_hour_table);
	
	
	shop_hour_holder.innerHTML = '<table><tr><td style="padding:0;"><SPAN class="title">Business Hours :  </SPAN></td><td style="padding:0 0 0 5px;">'+hour+'</td></tr></table>';
	
	
	
//	shop_hour_table.innerHTML = '<tr><td>abc</td></tr>';
	
	//shop shop tel
	// <div class="shop_tel"><span class="title">Tel :</span> '+tel+'</div>
	//var shop_tel_txt = document.createTextNode(tel);
	var shop_tel_txt= document.createElement('SPAN');
	shop_tel_txt.innerHTML = tel;
	var shop_tel = document.createElement('SPAN');
	shop_tel.setAttribute("class", 'title');
	shop_tel.className = 'title';
	shop_tel.innerHTML = 'Tel. : ';

	var shop_tel_div = document.createElement('DIV');
	shop_tel_div.setAttribute("class", 'shop_tel');
	shop_tel_div.appendChild(shop_tel);
	shop_tel_div.appendChild(shop_tel_txt);

	//shop location
	// <div class="toLeft"><span class="title">Location :</span> The Palace G/F & 1/F</div>
	//var shop_loc_txt = document.createTextNode(loc);
	var shop_loc_txt= document.createElement('SPAN');
	shop_loc_txt.innerHTML = loc;
	var shop_loc = document.createElement('SPAN');
	shop_loc.setAttribute("class", 'title');
	shop_loc.className = 'title';
	shop_loc.innerHTML = 'Location : ';

	var shop_loc_div = document.createElement('DIV');
	shop_loc_div.setAttribute("class", 'toLeft');
	shop_loc_div.appendChild(shop_loc);
	shop_loc_div.appendChild(shop_loc_txt);

	//shop description
	var shop_desc = document.createElement('DIV');
	shop_desc.innerHTML = desc;

	//create shop detail
	var shop_detail_div = document.createElement('DIV');
	shop_detail_div.setAttribute("class", 'shop_detail');
	
	//if (getTree()[0] != 'fun')
//		{
			shop_detail_div.appendChild(shop_name);
			shop_detail_div.appendChild(shop_name_txt);
			shop_detail_div.appendChild(document.createElement('BR'));
		//}
	
	
	
	if (hour!='') shop_detail_div.appendChild(shop_hour_holder);
	
	//shop_detail_div.appendChild(shop_hour);
	//shop_detail_div.appendChild(shop_hour_txt);
//	shop_detail_div.appendChild(shop_hour_table);
	
	
	if (tel!='') shop_detail_div.appendChild(shop_tel_div);
	if (loc!='') shop_detail_div.appendChild(shop_loc_div);
	shop_detail_div.appendChild(document.createElement('BR'));
	if (!isIE)
		{
			shop_detail_div.appendChild(document.createElement('BR'));
			shop_detail_div.appendChild(document.createElement('BR'));
		}
	shop_detail_div.appendChild(shop_desc);


	//craete shop_content div
	var shop_content_div = document.createElement('DIV');
	shop_content_div.setAttribute("class","shop_content");
	shop_content_div.className = 'shop_content';
	shop_content_div.appendChild(shop_logo_div);
	shop_content_div.appendChild(shop_detail_div);

	//=-====================================================
	//=-====================================================
	

//	var image_right_str = '<div id="highlight" style="position:absolute; top:295px; left:53px;"><img src="../images/photo_highlight.gif" alt="" /></div>';
//	image_right_str += '<div class="photo_frame"><img src="../images/frame_lrg.png" alt="" width="256" height="192" class="pngImg" /></div>';
	var image_right_str = '';
	if (shop.galleries>0)
		{
			var image_right_str = '<div id="highlight" style="position:absolute; top:295px; left:53px;"><img src="../images/photo_highlight.gif" alt="" /></div>';
			image_right_str += '<div class="photo_frame"><img src="../images/frame_lrg.png" alt="" width="256" height="192" class="pngImg" /></div>';
			
			image_right_str += '<div><img id="largeImg" src="../images/'+getTree()[0]+'/photo/'+id+'_img_1_lrg.jpg" alt="" /></div>';
			for (var i=1; i<=shop.galleries; i++)
				{
					image_right_str += '<div class="photo_frame_border"><a href="javascript:changeImg(\''+id+'\','+i+');"><img src="../images/'+getTree()[0]+'/photo/'+id+'_img_'+i+'.jpg" alt="" border="0" /></a></div>';
				}
		}
	else
		{
			image_right_str += '<div class="photo_frame"><img src="../images/frame_lrg.png" alt="" width="256" height="192" class="pngImg" /></div>';
			image_right_str += '<div><img id="largeImg" src="../images/img_list.jpg" alt="" /></div>';
		}
	

		
	var image_right_div = document.createElement('DIV');
	image_right_div.setAttribute("class","image_right");
	image_right_div.className = 'image_right';
	image_right_div.innerHTML = image_right_str;	
	
	
	var container = document.getElementById('contentContainer');
	
	container.appendChild(shop_content_div);
	
	// if (shop.galleries>0)
		// {
			container.appendChild(image_right_div);
		// }
	
	container.appendChild(clearer);
	
	updateSubNav(shop);
}

function updateSubNav(shop)
{
	var pervBtn = document.getElementById('shop_prev');
	var nextBtn = document.getElementById('shop_next');
	var backBtn = document.getElementById('shop_back');
	
	var pnObj = getPervAndNextShopByID(shop.id);
	
	var curSec = getTree()[0];
	var cat = GetParam('cat');
	var pre = GetParam('pre');
	
	var ch0 = curSec.charAt(0).toUpperCase();
	var tit = ch0 + curSec.slice(1,curSec.length);
	
	//backBtn.innerHTML = '<a href="../?section='+curSec+'&cat='+cat+'&pre='+pre+'">Back to '+tit+' Directory</a>';
	backBtn.innerHTML = '<a href="../?section='+curSec+'&cat='+cat+'&pre='+'all'+'">Back to '+tit+' Directory</a>';

		
	
	if ((pnObj.perv.id) && (pnObj.perv.id!=''))
		{
		//alert(pnObj.perv.id + " : " + shop.id + " : " + pnObj.next.id);
			if (pnObj.perv.link != '')
				{
					pervBtn.innerHTML = '<a href='+pnObj.perv.link+'>Previous Shop Name</a>';
				}
			else
				{
					pervBtn.innerHTML = '<a href=detail.html?id='+pnObj.perv.id+'>Previous Shop Name</a>';
				}
		}
		
	if ((pnObj.next.id) && (pnObj.next.id!=''))
		{
			if (pnObj.next.link != '')
				{
					nextBtn.innerHTML = '<a href='+pnObj.next.link+'>Next Shop Name</a>';
				}
			else
				{
					nextBtn.innerHTML = '<a href=detail.html?id='+pnObj.next.id+'>Next Shop Name</a>';
				}
		}
		
		
	// var titleImage = document.getElementById('titleImage');
	// if (shop.link != '')
		// {
			//titleImage.innerHTML = '<img src="../images/fun/title_'+shop.id+'.gif" alt="Fun" />';
		//}
}
	
	