// JavaScript Document

var d = document;
var selected = '';
if (!section)	var section = "";
var user='undefined';
function contains(string,substr,isIgnoreCase)
{
    if(isIgnoreCase)
    {
     string=string.toLowerCase();
     substr=substr.toLowerCase();
    }
     var startChar=substr.substring(0,1);
     var strLen=substr.length;
         for(var j=0;j<string.length-strLen+1;j++)
         {
             if(string.charAt(j)==startChar)//如果匹配起始字符,开始查找
             {
                   if(string.substring(j,j+strLen)==substr)//如果从j开始的字符与str匹配，那ok
                   {
                         return true;
                   }  
             }
         }
         return false;
}
function checkAjax()
{
        if (window.XMLHttpRequest)
        {
                // If IE7, Mozilla, Safari, etc: Use native object
                //exploer = "true";
                return new XMLHttpRequest();
        }
        else
        {
                if (window.ActiveXObject)
                {
                        //exploer = "false";
                // ...otherwise, use the ActiveX control for IE5.x and IE6
//                        try
//                        { 
//                                return new ActiveXObject("MSXML2.ServerXMLHTTP");
//                        }
//                        catch (err)
//                        {
                                return new ActiveXObject("Microsoft.XMLHTTP");
//                        }
                }
        }
        return false;
}

function onBooking(id) {
		var selectedDay = document.getElementById(id);
		var selectedDay2 = document.getElementById(selected);
		
		var nextBtn = document.getElementById('nextBtn');
		
		
		selectedDay.onmouseover = function() {			
			selectedDay.style.backgroundColor = '#5BA425';				
		}
		
		selectedDay.onclick = function() {
			//var selectedDay2 = document.getElementById(id);
			if (document.getElementById(selected)) {
				selectedDay2.style.backgroundColor = '#B79277';
			}
			nextBtn.style.background = 'url(/UREC/html/en/images/next_on.gif) no-repeat';
			selectedDay.hit = true;				
			selected = id;
		}
		
		selectedDay.onmouseout = function() {	
			
				selectedDay.style.backgroundColor = '#B79277';
				//selectedDay2.style.backgroundColor = '#5BA425';				
			
		}
		if (document.getElementById(selected)) {
		selectedDay2.style.backgroundColor = '#5BA425';	
		}
		
}

function checkBooking(id) {
		var selectedDay = document.getElementById(id);
		var selectedDayDetail = document.getElementById(id + '_detail');
		
		
		selectedDay.onmouseover = function() {
			selectedDay.style.backgroundColor = '#FFCC00';
		selectedDay.style.color = '#906C4D';
		selectedDayDetail.style.display = 'block';
		}
		
		selectedDay.onmouseout = function() {
			selectedDayDetail.style.display = 'none';
			
			selectedDay.style.backgroundColor = '#B79277';
			selectedDay.style.color = '#FFFFFF';
			
		}
}


//change what's news tab
var tabList = new Array('upcomingBtn', 'highlightBtn');

function changeTab(id) {
		var tabBtn = document.getElementById(id);
		var tabBtnLink = document.getElementById(id + '_link');
		var content = document.getElementById('upcomingBtnContent');
		var content2 = document.getElementById('highlightBtnContent');
		
		var upcomingBtn = document.getElementById('upcomingBtn');
		var highlightBtn = document.getElementById('highlightBtn');
		
		var upcomingBtnLink = document.getElementById('upcomingBtn_link');
		var highlightBtnLink = document.getElementById('highlightBtn_link');
		
		if (id == tabList[0]) {
				tabBtn.style.background = 'url(images/news_tab_on.gif) no-repeat';
				tabBtnLink.style.color = '#F2AA00';
				highlightBtn.style.background = 'url(images/news_tab2.gif) no-repeat';
				highlightBtnLink.style.color = '#D7BAA3';
				content2.style.display = 'none';
				content.style.display = 'block';
				
		} else {
				tabBtn.style.background = 'url(images/news_tab2_on.gif) no-repeat';
				tabBtnLink.style.color = '#F2AA00';
				upcomingBtn.style.background = 'url(images/news_tab.gif) no-repeat 2px 0px';
				upcomingBtnLink.style.color = '#D7BAA3';
				content.style.display = 'none';
				content2.style.display = 'block';
		}
		
		
}

//larger past event image
function largerImg(id) {
		var bigImg = document.getElementById('displayImg');
		bigImg.src = 'images/' + id +'.jpg';
		
		
}

function genFlash(file, width, height, id, vars){
var xmlhttp = checkAjax();
   if (!xmlhttp)
               {
                       alert('Your browser does not support multiple page print!');
                       return;
               }
               xmlhttp.open("POST","../CheckLogin.aspx",true);
       var mimeType = (xmlhttp.overrideMimeType)?true:false;
      if (mimeType)
                {
                        xmlhttp.overrideMimeType("text/html;charset=UTF-8");
                }
        else
                    {
                            xmlhttp.setRequestHeader("content-type","text/html; charset=UTF-8");
                    }
        xmlhttp.send('dd');
            xmlhttp.onreadystatechange=function()
                {
                   if(xmlhttp.readyState=='4'&&(xmlhttp.status == '200'||xmlhttp.status == '12030'||xmlhttp.status == '12031'))
                        {
                          user=xmlhttp.responseText;
                          vars+='&user='+user;
                          OriginalgenFlash(file, width, height, id, vars);
   }
}
}
//GenNav
function OriginalgenFlash(file, width, height, id, vars) {
if(contains(pageSrc,'secondary_web/content/tc_',0)){
   pageSrc=pageSrc.replace(/tc_/i, "en_");
}else if(contains(pageSrc,'secondary_web/content/en_',0)){
    pageSrc=pageSrc.replace(/en_/i, "tc_");
}
vars=vars+'&RegisterPath=subscription.aspx&MemberLoginPath=login.aspx&MemberLogoutPath=/html/Logout.aspx?lang=chi&pageSrc='+pageSrc;
 
 var tempHtml = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'">';
 tempHtml += '<param name="movie" value="'+file+'">';
 tempHtml += '<param name="quality" value="high">';
 tempHtml += '<param name="menu" value="false">';
 tempHtml += '<param name="wmode" value="transparent">';
 tempHtml += '<param name="scale" value="noscale">'; 

 if (vars != null) {
  tempHtml += '<param name="flashVars" value="'+vars+'">';
  tempHtml += '<embed src="'+file+'" flashVars="'+vars+'" quality="high" scale="noscale" wmode="transparent" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
 } else {
  tempHtml += '<embed src="'+file+'" quality="high" scale="noscale" wmode="transparent" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+width+'" height="'+height+'" id="'+id+'" name="'+id+'"></embed>';
 }
 
 tempHtml += '</object>';
document.getElementById('flashPlace').innerHTML=tempHtml;
}

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 GenNav()
{
var xmlhttp = checkAjax();
   if (!xmlhttp)
               {
                       alert('Your browser does not support multiple page print!');
                       return;
               }
               xmlhttp.open("POST","../CheckLogin.aspx",true);
       var mimeType = (xmlhttp.overrideMimeType)?true:false;
      if (mimeType)
                {
                        xmlhttp.overrideMimeType("text/html;charset=UTF-8");
                }
        else
                    {
                            xmlhttp.setRequestHeader("content-type","text/html; charset=UTF-8");
                    }
        xmlhttp.send(null);
            xmlhttp.onreadystatechange=function()
                {
                   if(xmlhttp.readyState=='4'&&(xmlhttp.status == '200'||xmlhttp.status == '12030'||xmlhttp.status == '12031'))
                        {
                          user=xmlhttp.responseText;
                          //user='&user='+user;
                          OriginalGenNav();
                           }
}
}
function OriginalGenNav()
{
var temp = GetParam("gosection");
	if (temp == "")
	{
		temp=undefined;
	}
	var eventID= document.getElementById('Event_ID');
	var eventYear= document.getElementById('eventYear');
	if(eventID!=null&&eventID.value!=null&&eventID.value!=""){
	genFlash('swf/nav.swf', '310', '210', 'nav','HomePath=home.html&EduPath=/html/chi/primary_web/index.html&NewsPath=event_highlight_with_post_comment.aspx&GalleryPath=media_gallery.html&SubscriptionPath=login.aspx&ContactPath=contact.html&LangPath=/html/en/'+pageSrc+'?EventID='+eventID.value+'&gosection='+section+'&user='+user);
	}else if(eventYear!=null&&eventYear.value!=null&&eventYear.value!=""){
	genFlash('swf/nav.swf', '310', '210', 'nav','HomePath=home.html&EduPath=/html/chi/primary_web/index.html&NewsPath=event_highlight_with_post_comment.aspx&GalleryPath=media_gallery.html&SubscriptionPath=login.aspx&ContactPath=contact.html&LangPath=/html/en/'+pageSrc+'?eventYear='+eventYear.value+'&gosection='+section+'&user='+user);
	}else{
	genFlash('swf/nav.swf', '310', '210', 'nav','HomePath=home.html&EduPath=/html/chi/primary_web/index.html&NewsPath=event_highlight_with_post_comment.aspx&GalleryPath=media_gallery.html&SubscriptionPath=login.aspx&ContactPath=contact.html&LangPath=/html/en/'+pageSrc+'?gosection='+section+'&user='+user);
	}
	//alert("EventID:"+eventID.value);
	//alert("eventYear:"+eventYear.value);
}
function GenNav2()
{
var xmlhttp = checkAjax();
   if (!xmlhttp)
               {
                       alert('Your browser does not support multiple page print!');
                       return;
               }
               xmlhttp.open("POST","../CheckLogin.aspx",true);
       var mimeType = (xmlhttp.overrideMimeType)?true:false;
      if (mimeType)
                {
                        xmlhttp.overrideMimeType("text/html;charset=UTF-8");
                }
        else
                    {
                            xmlhttp.setRequestHeader("content-type","text/html; charset=UTF-8");
                    }
        xmlhttp.send(null);
            xmlhttp.onreadystatechange=function()
                {
                   if(xmlhttp.readyState=='4'&&(xmlhttp.status == '200'||xmlhttp.status == '12030'||xmlhttp.status == '12031'))
                        {
                          user=xmlhttp.responseText;
                          OriginalGenNav2();
                           }
}
}
function OriginalGenNav2()
{
var temp = GetParam("gosection");
	if (temp == "")
	{
		temp=undefined;
	}
	var eventID= document.getElementById('Event_ID');
	var eventYear= document.getElementById('eventYear');
	if(eventID!=null&&eventID.value!=null&&eventID.value!=""){
	genFlash('swf/nav.swf', '310', '210', 'nav','HomePath=home.html&EduPath=/html/chi/primary_web/index.html&NewsPath=event_highlight_with_post_comment.aspx&GalleryPath=media_gallery.html&SubscriptionPath=login.aspx&ContactPath=contact.html&LangPath=/html/en/'+pageSrc+'?EventID='+eventID.value+'&gosection='+section+'&user='+user);
	}else if(eventYear!=null&&eventYear.value!=null&&eventYear.value!=""){
	genFlash('swf/nav.swf', '310', '210', 'nav','HomePath=home.html&EduPath=/html/chi/primary_web/index.html&NewsPath=event_highlight_with_post_comment.aspx&GalleryPath=media_gallery.html&SubscriptionPath=login.aspx&ContactPath=contact.html&LangPath=/html/en/'+pageSrc+'?eventYear='+eventYear.value+'&gosection='+section+'&user='+user);
	}else{
	genFlash('swf/nav.swf', '310', '210', 'nav','HomePath=home.html&EduPath=/html/chi/primary_web/index.html&NewsPath=event_highlight_with_post_comment.aspx&GalleryPath=media_gallery.html&SubscriptionPath=login.aspx&ContactPath=contact.html&LangPath=/html/en/'+pageSrc+'?gosection='+section+'&user='+user);
	}

}


function genFlash3(file, width, height, id, vars){

var xmlhttp = checkAjax();

   if (!xmlhttp)
               {
                       alert('Your browser does not support multiple page print!');
                       return;
               }

               xmlhttp.open("POST","../../../CheckLogin.aspx",true);

       var mimeType = (xmlhttp.overrideMimeType)?true:false;
      if (mimeType)
                {
                        xmlhttp.overrideMimeType("text/html;charset=UTF-8");
                }
        else
                    {
                            
                            xmlhttp.setRequestHeader("content-type","text/html; charset=UTF-8");
                    }
     
        xmlhttp.send(null);
                   
            xmlhttp.onreadystatechange=function()
                {
               
                   if(xmlhttp.readyState=='4'&&(xmlhttp.status == '200'||xmlhttp.status == '12030'||xmlhttp.status == '12031'))
                        {
                       
                          user=xmlhttp.responseText;
                          vars+='&user='+user;
                          OriginalgenFlash(file, width, height, id, vars);

                            }
                        }
}

function GenNav3()
{

var temp = GetParam("gosection");
	if (temp == "")
	{
		temp=undefined;
		
	}
	 OriginalGenNav3();
   }


function OriginalGenNav3()
{
genFlash3('/html/chi/swf/nav.swf', '310', '210', 'nav','HomePath=/html/chi/home.html&NewsPath=/html/chi/event_highlight_with_post_comment.aspx&EduPath=/html/chi/primary_web/index.html&GalleryPath=/html/chi/media_gallery.html&SubscriptionPath=/html/chi/login.aspx&ContactPath=contact.html&LangPath=/html/en/'+pageSrc+'&gosection='+section+'&user='+user);
}//GenFooter



function genFlash4(file, width, height, id, vars){

var xmlhttp = checkAjax();

   if (!xmlhttp)
               {
                       alert('Your browser does not support multiple page print!');
                       return;
               }

               xmlhttp.open("POST","../../CheckLogin.aspx",true);

       var mimeType = (xmlhttp.overrideMimeType)?true:false;
      if (mimeType)
                {
                        xmlhttp.overrideMimeType("text/html;charset=UTF-8");
                }
        else
                    {
                            
                            xmlhttp.setRequestHeader("content-type","text/html; charset=UTF-8");
                    }
     
        xmlhttp.send(null);
                   
            xmlhttp.onreadystatechange=function()
                {
               
                   if(xmlhttp.readyState=='4'&&(xmlhttp.status == '200'||xmlhttp.status == '12030'||xmlhttp.status == '12031'))
                        {
                       
                          user=xmlhttp.responseText;
                          vars+='&user='+user;
                          OriginalgenFlash(file, width, height, id, vars);

                            }
                        }
}

function GenNav4()
{
var temp = GetParam("gosection");
	if (temp == "")
	{
		temp=undefined;
		
	}
	 OriginalGenNav4();
   }
   
function OriginalGenNav4()
{
genFlash4('/html/chi/swf/nav.swf', '310', '210', 'nav','HomePath=/html/chi/home.html&NewsPath=/html/chi/event_highlight_with_post_comment.aspx&EduPath=/html/chi/primary_web/index.html&GalleryPath=/html/chi/media_gallery.html&SubscriptionPath=/html/chi/login.aspx&ContactPath=contact.html&LangPath=/html/en/'+pageSrc+'&gosection='+section+'&user='+user);
}

function genFooter() {
	var tempHtml = '<div class="footer">';
	tempHtml += '<div class="clearfix"><div class="left"><img src="images/urban_logo.gif" alt="Urban Renewal Authority" /></div></div>';
	tempHtml += '<div class="clearfix"><div class="right"><a href="/html/chi/faq.html">常見問題</a>|<a href="/html/chi/sitemap.html">網站地圖</a>|<a href="/html/chi/policy.html">私隱聲明</a>|<a href="/html/chi/disclaimer.html">免責聲明</a>|<span>市區重建局 © 2009 <a href="/html/chi/copyright.html">版權告示</a>.</span></div></div>';
	tempHtml += '</div>';
	tempHtml += '<script type="text/javascript" language="javascript">';
	//tempHtml += 'init();';
	// tempHtml += 'setNewsNav.init(\'newsNav\', \'newsList\');';
	// tempHtml += 'listScroll.init(\'newsList\', \'Scrollbar-Container\', false);';
	tempHtml += '</script>';

	init();

	document.write(tempHtml);
}
function genFooter2() {
	var tempHtml = '<div class="footer">';
	tempHtml += '<div class="clearfix">&nbsp;</div>';
	tempHtml += '<div class="clearfix"><div class="right"><a href="/html/chi/faq.html">常見問題</a>|<a href="/html/chi/sitemap.html">網站地圖</a>|<a href="/html/chi/policy.html">私隱聲明</a>|<a href="/html/chi/disclaimer.html">免責聲明</a>|<span>市區重建局 © 2009 <a href="/html/chi/copyright.html">版權告示</a>.</span></div></div>';
	tempHtml += '</div>';
	tempHtml += '<script type="text/javascript" language="javascript">';
	//tempHtml += 'init();';
	// tempHtml += 'setNewsNav.init(\'newsNav\', \'newsList\');';
	// tempHtml += 'listScroll.init(\'newsList\', \'Scrollbar-Container\', false);';
	tempHtml += '</script>';

	init();

	document.write(tempHtml);
}

/*function genLeftLink() {

var tempHtml = '<div id="bookingBtn" class="clearfix">';
 	tempHtml += '<div class="left"><a  href="application.html"><img src="images/booking_for_visit.jpg" alt="Booking For Visit" /></a></div>';
 	tempHtml += '<div class="right"><a href="schedule.html">Check Schedule</a></div></div>';
			
 	tempHtml += '<div class="openHour clearfix"><div class="left">10:00 - 18:00 (close on Monday)</div></div>';
			
 	tempHtml += '<div class="address clearfix">';
 	tempHtml += '<div class="left">6/F, Low Block, Grand Milennium Plaza, 181 Queen\'s Road Centra, HK</div>';
 	tempHtml += '<div class="right"><a href="#"><img src="images/map.gif" alt="Map" /></a></div>';
 	tempHtml += '</div>';
 	tempHtml += '<div class="contact clearfix">';
 	tempHtml += '<div class="left">Enquiry Hotline : (852) 2588-2333</div>';
 	tempHtml += '</div>';
 	tempHtml += '<div class="" id="newsNav"><a href="#"><strong>Related Links</strong></a></div>';
	document.write(tempHtml);
}*/

function genLeftLink() {
var tempHtml = '<div id="newsList">';
 	tempHtml += '<div id="homeLink">';
 	tempHtml += '<h3>敬請預約參觀</h3>';
 	tempHtml += '<div id="bookingBtn" class="clearfix">';
 	tempHtml += '<div class="left"><a href="application.aspx"><img src="images/booking_for_visit.jpg" alt="預約參觀" /></a></div>';
 	tempHtml += '<div class="right"><a href="schedule.aspx">時間表</a></div>';
 	tempHtml += '</div>';
 	tempHtml += '<div class="openHour clearfix">';
 	tempHtml += '<div class="left">10:00 - 17:30 (星期一至五; 公眾假期除外)</div>';
 	tempHtml += '</div>';
 	tempHtml += '<div class="address clearfix">';
 	tempHtml += '<div class="left">香港皇后大道中181號新紀元廣場低座601室</div>';
 	//tempHtml += '<div class="right">&nbsp;</div>';
 	tempHtml += '</div>';
 	tempHtml += '<div class="contact clearfix">';
 	tempHtml += '<div class="left">電話查詢 : (852) 2588-2333</div>';
 	tempHtml += '</div>';
 	tempHtml += '<div class="relatedLink" id="newsNav"><a href="#"><strong>相關連結</strong></a></div>';
 	tempHtml += '</div>';
	tempHtml += '<div class"relatedSpec" style="padding:0px 0 0px 0;"></div>';
 	tempHtml += '<div id="homeLink_related">';
 	tempHtml += '<ul class="greendot">';
 	tempHtml += '<li><a href="http://www.ura.org.hk/html/c100000t1e.html" target="_blank">市區重建局</a></li>';
 	tempHtml += '<li><a href="http://www.ursreview.gov.hk/" target="_blank">市區重建策略檢討</a></li>';
 	tempHtml += '<li><a href="http://www.wrisc.org.hk/chi/index.htm" target="_blank">活化灣仔舊區專責委員會</a></li>';
 	tempHtml += '</ul>';
	//tempHtml += '<div style="padding:0 0 0 0;">&nbsp;</div>';
 	tempHtml += '<div class="relatedLink" id="newsNav">';
 	tempHtml += '<a href="#"><strong>相關連結</strong></a></div>';
 	tempHtml += '</div>';
 	//tempHtml += '<div id="newsHit" style="background:#333"><img src="images/spacer.gif" width="400" height="300" /></div>';
 	tempHtml += '<div id="newsHit"></div>';
 	tempHtml += '</div>';
	
	document.write(tempHtml);
}

function setBtnOver()
{
    var img = d.getElementsByTagName('img');
    
    for (var i=0; i<img.length; i++)
    {
        if (img[i].className != 'btnOver')    continue;
        if (img[i].src.indexOf('_over') >= 0)    img[i].clicked = true;
        
        img[i].onmouseover = function()
        {
            if (this.clicked)    return;
            var ext = this.src.substring(this.src.length-4, this.src.length);
            
            this.src = this.src.replace(ext, '_over' + ext);
        }
        
        img[i].onmouseout = function()
        {
            if (this.clicked)    return;
            var ext = this.src.substring(this.src.length-4, this.src.length);
            
            this.src = this.src.replace('_over' + ext, ext);
        }
    }
}

function init()
{
	setBtnOver();
	if (d.getElementById('newsNav'))	setNewsNav();
}


//related links
function setNewsNav()
{
	this.nav = d.getElementById('newsNav');
	this.homeLink = d.getElementById('homeLink');
	this.obj = d.getElementById('homeLink_related');
	this.newsHit = d.getElementById('newsHit');
	this.hit = true;
	this.hit1 = true;
	
	var self = this;
	var hello;
	
	this.init = function(nav, obj)
	{
		this.nav.onmouseover = function()
		{
			self.obj.style.display = 'block';
			self.newsHit.style.display = 'block';
			//startFading(self.obj);
			self.homeLink.style.display = 'none';
			clearTimeout(hello);
			hello = setTimeout(helloworld, 100);
		}

		this.newsHit.onmouseout = function()
		{
			self.hit1 = true;
			clearTimeout(hello);
			hello = setTimeout(helloworld, 100);
		}
		
		this.obj.onmouseout = function()
		{
			self.hit = true;
			clearTimeout(hello);
			hello = setTimeout(helloworld, 100);
		}
		
		this.obj.onmouseover = function()
		{
			self.hit = false;
			clearTimeout(hello);
			hello = setTimeout(helloworld, 100);
		}
		
		this.newsHit.onmouseover = function()
		{
//			self.newsHit.style.display = 'none';
//			alert(1);
			
			this.hit1 = false;
			clearTimeout(hello);
			hello = setTimeout(helloworld, 100);
			
			//self.newsHit.onmouseover = null;
		}

	}
	
	this.helloworld = function()
	{
		if (self.hit && self.hit1)
		{
			self.obj.style.display = 'none';
			self.newsHit.style.display = 'none';
			self.homeLink.style.display = 'block';
		}
		else
		{
			self.obj.style.display = 'block';
			self.newsHit.style.display = 'block';
			self.homeLink.style.display = 'none';
		}
		
	}

	this.init();
}

function startFading(el)
{
  if (el.fadinTimeout)	clearTimeout(el.fadinTimeout);
  el.style.visibility = 'visible';
  el.style.zIndex = 2;
  setOpacity(el, 0);
  fadeImage(el, 0);
}

function fadeImage(el, currentOpacity)
{
  currentOpacity += 10;

  if (currentOpacity > 100)
  {
    setOpacity(el, 100);
    el.style.zIndex = 1;
	if (el.fadinTimeout)	clearTimeout(el.fadinTimeout);
  }
  else
  {
    setOpacity(el, currentOpacity);
    el.fadinTimeout = setTimeout(function() { fadeImage(el, currentOpacity); }, 30);
  }
}

function setOpacity(el, opacity)
{
	opacity /= 100;
	el.style.opacity = opacity;
	el.style.MozOpacity = opacity;
	el.style.filter = "alpha(opacity=" + (opacity*100) + ")";
}

var listScroll = 
{
	init: function()
	{
	},
	
	changeList:	function(id)
	{
		listScroll.reset();
		
		var ul = this.container.getElementsByTagName('ul');
		for (var i=0; i<ul.length; i++)
		{
			ul[i].style.display = (i == id)	?	'block'	:	'none';
			if (!ul[i].isScroll)	continue;
			if (i == id)
			{
				var li = ul[i].getElementsByTagName('li');
				var total = li.length;
				var j = 0;
				while (j < total/2)
				{
					li[j].style.display = 'none';
					j ++;
				}
			}
		}
		
		this.id = id;
	}
}

function createImg(src, alt, w, h, link, t, className)
{
	var img = d.createElement('img');
	if (src)	img.setAttribute('src', src);
	if (alt)	img.setAttribute('alt', alt);
	if (w)	img.setAttribute('width', w);
	if (h)	img.setAttribute('height', h);
	if (className)	img.className = className;
	
	if (link)
	{
		img.setAttribute('border', 0);
		
		var a = d.createElement('a');
		a.setAttribute('href', link);
		if (t && typeof(t) != 'undefined')	a.setAttribute('target', t);
		a.appendChild(img);
		return a;
	}
	else
	{	
		return img;
	}
}

function createA(link, t, txt, id, className)
{		
	var a = d.createElement('a');
	if (link)	a.setAttribute('href', link);
	if (t && typeof(t) != 'undefined')	a.setAttribute('target', t);
	
	//if (txt)	a.appendChild(d.createTextNode(txt));
	if (txt)	a.innerHTML = txt;
	if (id)	a.setAttribute('id', id);
	if (className)	a.className = className;
	
	return a;
}

function createDiv(id, className, txt)
{		
	var div = d.createElement('div');
	if (id)	div.setAttribute('id', id);
	if (className)	div.className = className;
	//if (txt)	div.appendChild(d.createTextNode(txt));
	if (txt)	div.innerHTML = txt;
	return div;
}

function createTag(tag, id, className)
{		
	var div = d.createElement(tag);
	if (id)	div.setAttribute('id', id);
	if (className)	div.className = className;
	return div;
}

function createInput(name, type, value, className)
{		
	var input = d.createElement('input');
	if (name)	input.setAttribute('name', name);
	if (type)	input.setAttribute('type', type);
	if (value)	input.setAttribute('value', value);
	if (className)	input.className = className;
	return input;
}

function NewWindow(mypage, myname, w, h, scroll, resizable)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable='+resizable+','
	win = window.open(mypage, myname, winprops)
	win.self.focus()
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}