/* 
################################
# Author : Jimmy Lam S.K.      #
# Copyright (C) minami.net.my  #
# All Rights Reserved          #
################################
*/
var isIE = navigator.appName.indexOf("Microsoft") != -1;
var arVersion = navigator.appVersion.split("MSIE");
var version = parseFloat(arVersion[1]);

/*################################
# Prototype Function			 #
################################*/

String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };
String.prototype.openTag = function() { return this.replace(/##o##/g, '<'); };
String.prototype.closeTag = function() { return this.replace(/##c##/g, '>'); };
String.prototype.ConvertSmiley = function() {
	var context = this;
	context = context.replace(/\(\*\^_\^\*\)/g,'<img src=\'smiley/_128.gif\' />');
	context = context.replace(/=p/gi,'<img src=\'smiley/_131.gif\' />'); 
	context = context.replace(/:p/gi,'<img src=\'smiley/_131.gif\' />');
	context = context.replace(/=\)/g,'<img src=\'smiley/_102.gif\' />');
	context = context.replace(/:\)/g,'<img src=\'smiley/_102.gif\' />');
	context = context.replace(/:&gt;/g,'<img src=\'smiley/_106.gif\' />');
 	context = context.replace(/=&gt;/g,'<img src=\'smiley/_106.gif\' />');
	context = context.replace(/\^\^;/g,'<img src=\'smiley/_105.gif\' />'); 
	context = context.replace(/\^\^/g,'<img src=\'smiley/_105.gif\' />');
	context = context.replace(/\^-\^/g,'<img src=\'smiley/_105.gif\' />');
	context = context.replace(/\^_\^/g,'<img src=\'smiley/_105.gif\' />');
	context = context.replace(/:D/gi,'<img src=\'smiley/_103.gif\' />');
	context = context.replace(/=D/gi,'<img src=\'smiley/_103.gif\' />');
	context = context.replace(/:\|/g,'<img src=\'smiley/_126.gif\' />');
	context = context.replace(/=\|/g,'<img src=\'smiley/_126.gif\' />');
	context = context.replace(/:\(/g,'<img src=\'smiley/_116.gif\' />');
	context = context.replace(/=\(/g,'<img src=\'smiley/_116.gif\' />');
	context = context.replace(/:;\(/g,'<img src=\'smiley/_138.gif\' />');
	context = context.replace(/=;\(/g,'<img src=\'smiley/_138.gif\' />');
	context = context.replace(/:x/gi,'<img src=\'smiley/_125.gif\' />');
	context = context.replace(/=x/gi,'<img src=\'smiley/_125.gif\' />');
	context = context.replace(/oO/g,'<img src=\'smiley/_120.gif\' />');
	context = context.replace(/Oo/g,'<img src=\'smiley/_120.gif\' />');
	context = context.replace(/o_o/gi,'<img src=\'smiley/_120.gif\' />');
	context = context.replace(/o_O/g,'<img src=\'smiley/_120.gif\' />');
	context = context.replace(/O_o/g,'<img src=\'smiley/_120.gif\' />');
	context = context.replace(/=~/g,'<img src=\'smiley/_117.gif\' />');
	context = context.replace(/:~/g,'<img src=\'smiley/_117.gif\' />');
	context = context.replace(/:~/g,'<img src=\'smiley/_117.gif\' />');
	context = context.replace(/;\)/g,'<img src=\'smiley/_107.gif\' />');
	context = context.replace(/;\>/g,'<img src=\'smiley/_107.gif\' />');
	context = context.replace(/;\&gt;/g,'<img src=\'smiley/_107.gif\' />');
	context = context.replace(/-_-'/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/=_='/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/=.='/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/-.-'/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/-_-"/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/=_="/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/=.="/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/-.-"/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/-_-&quot;/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/=_=&quot;/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/=.=&quot;/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/-.-&quot;/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/-_-/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/=_=/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/=.=/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/-.-/g,'<img src=\'smiley/_139.gif\' />');
	context = context.replace(/=\\/g,'<img src=\'smiley/_119.gif\' />');
	context = context.replace(/=\//g,'<img src=\'smiley/_119.gif\' />');
	context = context.replace(/B\)/gi,'<img src=\'smiley/_121.gif\' />');
	context = context.replace(/B>/gi,'<img src=\'smiley/_121.gif\' />');
	context = context.replace(/B&gt;/gi,'<img src=\'smiley/_121.gif\' />');
	context = context.replace(/=o/gi,'<img src=\'smiley/_113.gif\' />');
	context = context.replace(/:o/gi,'<img src=\'smiley/_113.gif\' />');
	context = context.replace(/=&lt;/g,'<img src=\'smiley/_113.gif\' />');
	context = context.replace(/:&lt;/g,'<img src=\'smiley/_113.gif\' />');
	context = context.replace(/xX/g,'<img src=\'smiley/_140.gif\' />');
	context = context.replace(/Xx/g,'<img src=\'smiley/_140.gif\' />');
	context = context.replace(/x_x/gi,'<img src=\'smiley/_140.gif\' />');
	context = context.replace(/zZ/g,'<img src=\'smiley/_134.gif\' />');
	context = context.replace(/Zz/g,'<img src=\'smiley/_134.gif\' />');
	context = context.replace(/&gt;&lt;/g,'<img src=\'smiley/_137.gif\' />');
	context = context.replace(/&gt;.&lt;/g,'<img src=\'smiley/_137.gif\' />');
	context = context.replace(/\*\*/g,'<img src=\'smiley/_129.gif\' />');
	return context;
}

/*################################
# Get scroll top and left        #
################################*/

function getScrollTop() {
  return document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
}

function getScrollLeft() {
  return document.body.scrollLeft ? document.body.scrollLeft : document.documentElement.scrollLeft;
}


/*################################
# Get available window size      #
################################*/

function getWindowWidth() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientWidth:document.body.clientWidth;
}
 
function getWindowHeight() {
  return document.compatMode=='CSS1Compat' && !window.opera?document.documentElement.clientHeight:document.body.clientHeight;
}

function getPageSizeWithScroll(){
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		yWithScroll = document.body.scrollHeight;
		xWithScroll = document.body.scrollWidth;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		yWithScroll = document.body.clientHeight + document.body.offsetTop + 15;
		xWithScroll = document.body.clientWidth + document.body.offsetLeft + 10;
  	}
	return new Array(xWithScroll,yWithScroll);
}

/*################################
# To get elements base on class  #
################################*/

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

/*#################################
# In getting element left/top/w/h #
#################################*/
	
function getElementLeft(el) {
	var ol=el.offsetLeft;
	while ((el=el.offsetParent) != null) { ol += el.offsetLeft; }
	return ol;
}

function getElementTop(el) {
	var ot=el.offsetTop;
	while((el=el.offsetParent) != null) { ot += el.offsetTop; }
	return ot;
}

function getElementWidth(el) {	 
	return el.offsetWidth;
}

function getElementHeight(el) {
	return el.offsetHeight;
}

/*################################
# To generate loading message    #
################################*/

function doGenerateLoading(ntext) {
	
	var ele = document.getElementById("displayLoading");
	
    if (ele) {
        doChangeLoading(ntext);
    } else {		
		var displayedLoading = new displayLoading();
		displayedLoading.ntext = ntext;
		displayedLoading.Create();
	}
	
}

function doClearLoading() {
    var ele = document.getElementById("displayLoading");
    if (ele) {
        document.body.removeChild(ele);
    }
}

function doChangeLoading(ntext) {
    var ele = document.getElementById("displayLoading");
    if (ele) {
        ele.innerHTML = "<img src='images/loading.gif' ><br /><b style='14px;'>"+ntext+"</b>";
    }
}

function displayLoading() {
    
    var me = this;
	this.ntext = "Loading, please wait ...";
    
    this.Create = function() {
        if (document.body) {
			var ele = document.createElement("DIV");
			ele.id = "displayLoading";
			ele.className = "displayLoading";
			ele.align = "center";             
			ele.style.zIndex = "6000";
			ele.style.position = "absolute";
			ele.style.border = "2px solid #CCCCCC";
			ele.style.background = "#FFFFFF";
			ele.style.color = "#000000";
			ele.style.padding = "10px";
						
			ele.innerHTML = "<img src='images/loading.gif' ><br /><b style='14px;'>"+this.ntext+"</b>";
			
			document.body.appendChild(ele);
        } else {
            document.writeln("<div align='center' id='displayLoading' class='displayLoading' style='border: 2px solid #cccccc; padding: 10px; background:#FFFFFF; color:#000000; z-index: 6000; position: absolute;'><img src='images/loading.gif'/><br/><b style='font-size:14px;'>"+this.ntext+"</b></div>");
        }
		
		// dynamic position for dynamic height width
		var ele = document.getElementById("displayLoading");
		
		if (ele) {	
		
			var eleWidth = getElementWidth(ele);
			var eleHeight = getElementHeight(ele);		

			if ( (eleWidth > 0) && (eleHeight > 0) ) {
				var topPos = (getWindowHeight() / 2) - (eleHeight / 2) + getScrollTop();
				var leftPos = (getWindowWidth() / 2) - (eleWidth / 2) + getScrollLeft();
					
				ele.style.top = topPos + "px";
				ele.style.left = leftPos + "px";
			}		
		}
    }
}

/*################################
# To generate thank message      #
################################*/

function doGenerateMessage(ntext,timeOut) {
	var ele = document.getElementById("displayMessage");
    if (ele) {
        doChangeMessage(ntext);
    } else {
		var displayedMessage = new displayMessage();		
		displayedMessage.timeOut = timeOut;
		displayedMessage.ntext = ntext;
		displayedMessage.Create();
	}
}

function doClearMessage() {
    var ele = document.getElementById("displayMessage");
    if (ele) {
        document.body.removeChild(ele);
    }
}

function doChangeMessage(ntext) {
    var ele = document.getElementById("displayMessage");
    if (ele) {
        ele.innerHTML = "<img src='images/thanks.gif' ><br /><b style='14px;'>"+ntext+"</b>";
    }
}

function displayMessage() {
    
    var me = this;
	this.ntext = "Thank You";
	this.timeOut = 5000;
    
    this.Create = function() {
        if (document.body) {
			
			var chkDiv = document.getElementById("displayMessage");
			if (chkDiv) { document.body.removeChild(chkDiv); }
			
			var ele = document.createElement("DIV");
			ele.id = "displayMessage";
			ele.className = "displayMessage";
			ele.align = "center";             
			ele.style.zIndex = "6000";
			ele.style.position = "absolute";
			ele.style.border = "2px solid #CCCCCC";
			ele.style.background = "#FFFFFF";
			ele.style.color = "#000000";
			ele.style.padding = "10px";
			
			ele.innerHTML = "<img src='images/thanks.gif' ><br /><b style='14px;'>"+this.ntext+"</b>";
			
			document.body.appendChild(ele);
			
			// dynamic position for dynamic height width
			var ele = document.getElementById("displayMessage");
			
			if (ele) {	
			
				var eleWidth = getElementWidth(ele);
				var eleHeight = getElementHeight(ele);		
	
				if ( (eleWidth > 0) && (eleHeight > 0) ) {
					var topPos = (getWindowHeight() / 2) - (eleHeight / 2) + getScrollTop();
					var leftPos = (getWindowWidth() / 2) - (eleWidth / 2) + getScrollLeft();
						
					ele.style.top = topPos + "px";
					ele.style.left = leftPos + "px";
				}		
			}
			
			window.setTimeout(doClearMessage, this.timeOut);
        }
    }
}

/*################################
# To generate clock              #
################################*/

function doGenereDate() {
    
  var currentDate = new Date();
  document.writeln(currentDate.getDate()+" / "+currentDate.getMonth()+" / "+currentDate.getFullYear()); 
  
}

function doGenerateClock() {
    setInterval('updateClock()', 1000 );
}

function updateClock ( )
{
  var currentTime = new Date ( );

  var currentHours = currentTime.getHours ( );
  var currentMinutes = currentTime.getMinutes ( );
  var currentSeconds = currentTime.getSeconds ( );

  // Pad the minutes and seconds with leading zeros, if required
  currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
  currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

  // Choose either "AM" or "PM" as appropriate
  var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

  // Convert the hours component to 12-hour format if needed
  currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

  // Convert an hours component of "0" to "12"
  currentHours = ( currentHours == 0 ) ? 12 : currentHours;

  // Compose the string for display
  var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

  // Update the time display
  document.getElementById("clock").innerHTML = currentTimeString;
}


/*################################
# To render PNG in IE7 and below #
################################*/

function fixPNG(myImage) 
{
    if ((version >= 5.5) && (version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}


/*################################
# Debugging purpose only         #
################################*/

function createDebug() {
	var debug = document.createElement("DIV");
	debug.id = "debug";
	debug.style.display = "block";
	debug.style.top = "10px";
	debug.style.right = "10px";
	debug.style.position = "absolute";
	debug.style.border = "1px solid #FF0000";
	debug.style.padding = "5px;";
	
	debug.innerHTML = "My Debug Message : <br />";
	document.body.appendChild(debug);
}

function displayDebug(value) {
	if (!document.getElementById('debug')) {
		createDebug()
	}
	
	var debug = document.getElementById('debug');
	debug.innerHTML += value+"<br />";	
}

function appendDebug(element) {
	if (!document.getElementById('debug')) {
		createDebug()
	}
	
	var debug = document.getElementById('debug');	
	debug.appendChild(element);
	debug.style.display = "block";
}

function alertDebug(value) {
	alert(value);
}

/*################################
# In loading xml documents       #
################################*/

function AjaxLoadXML(url) {
	if (isIE) {
		xmlFeed = new ActiveXObject("Microsoft.XMLDOM");
		xmlFeed.async=false;
		xmlFeed.load(url);		
	} else {
		xmlFeed = document.implementation.createDocument("", "", null);
		xmlFeed.async=false;
		xmlFeed = AjaxLoadDataWithMimeType(url);
	}
		
	if (typeof xmlFeed != "undefined") return xmlFeed;
}

function AjaxLoadDataWithMimeType(url) {
		
	oxmlhttp = null;
	
	try {
		oxmlhttp = new XMLHttpRequest();
		oxmlhttp.overrideMimeType("text/xml");
	}
	catch(e) {
		try {
			oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			return null;
		}
	}
		
	if (!oxmlhttp) return null;
		
	try {
		oxmlhttp.open("GET", url, false);
		oxmlhttp.send(null);
	}
	catch(e) {                
		return null;
	}
		
	return oxmlhttp.responseXML;
}

/*################################
# In getting element source      #
################################*/

function getEventSource(e)
{
	if(isIE) {
		return window.event.srcElement;
	} else {
		return e.target;
	}
}

/*################################
# In handling cookies		 #
################################*/

function createCookie (name,value,time) {
	if (time) {
		var date = new Date();
		date.setTime(date.getTime()+time);
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
		
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	
	}
	return null;
}

function eraseCookie (name) {
	createCookie(name,"",-1);
}

/*################################
# Draggable window	         	 #
################################*/

var Drag = {
	obj : null,
	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)	{
		
		o.onmousedown	= Drag.start;
		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;
		o.root = oRoot && oRoot != null ? oRoot : o ;
		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";
		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;
		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;
		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},
	
	start : function(e) {
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);
		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;
		if (o.hmode) {
		if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
		if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
		if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
		if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}
		if (o.vmode) {
		if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
		if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
		if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
		if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}
		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;
	return false;
	},
	
	drag : function(e) {
		e = Drag.fixE(e);
		var o = Drag.obj;
		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;
		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);
		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));
		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)
		//Drag.obj.style.zIndex = Drag.obj.style.zIndex + 2;
		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;
		Drag.obj.root.onDrag(nx, ny);
	return false;
	},
	
	end : function() {
		document.onmousemove = null;
		document.onmouseup   = null;
		//Drag.obj.style.zIndex = Drag.obj.style.zIndex - 2;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
		parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},
		
	fixE : function(e) {
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
	return e;
	}
};


/*################################
# Fading Animation	         	 #
################################*/

/* Fade setting */
var fadingTimeOut 		= 50; 			// millisecond | fading time out
var maxFadeOpacityIn 	= 100; 			// 0 - 100 | max opacity to fade in
var eachFadeInValue 	= 25; 			// 0 - 100 | fade in value - increase value to faster the fading
//var timeFade;
// asigning id
function doFadeElement(divID,opacity) {
	
	var div = document.getElementById(divID);
	
	if (div) {
		if (opacity <= maxFadeOpacityIn  ) {
			
			opacity += eachFadeInValue;	
			div.style.opacity= '.'+opacity.toPrecision(2);
			div.style.filter = 'alpha(opacity='+opacity+')'; 
			
				if (opacity > maxFadeOpacityIn ) {	
					
					div.style.opacity = ""; // FF
					div.style.filter = ""; // IE bug with text
					
					//if (timeFade) window.clearTimeout(timeFade);					
				} else {
					//timeFade = window.setTimeout("doFadeElement('"+divID+"',"+opacity+")", fadingTimeOut);					
					window.setTimeout("doFadeElement('"+divID+"',"+opacity+")", fadingTimeOut);
					
				}
			}
	}	
}

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 


/*################################
# Animation	                 	 #
################################*/

function animate(elementID, newLeft, newTop, newWidth,
      newHeight, time, callback)
{
  var el = document.getElementById(elementID);
  if(el == null)
    return;
 
  var cLeft = parseInt(el.style.left);
  var cTop = parseInt(el.style.top);
  var cWidth = parseInt(el.style.width);
  var cHeight = parseInt(el.style.height);
 
  var totalFrames = 1;
  if(time> 0)
    totalFrames = time/40;

  var fLeft = newLeft - cLeft;
  if(fLeft != 0)
    fLeft /= totalFrames;
 
  var fTop = newTop - cTop;
  if(fTop != 0)
    fTop /= totalFrames;
 
  var fWidth = newWidth - cWidth;
  if(fWidth != 0)
    fWidth /= totalFrames;
 
  var fHeight = newHeight - cHeight;
  if(fHeight != 0)
    fHeight /= totalFrames;
   
  doFrame(elementID, cLeft, newLeft, fLeft,
      cTop, newTop, fTop, cWidth, newWidth, fWidth,
      cHeight, newHeight, fHeight, callback);
}

function doFrame(eID, cLeft, nLeft, fLeft,
      cTop, nTop, fTop, cWidth, nWidth, fWidth,
      cHeight, nHeight, fHeight, callback)
{
   var el = document.getElementById(eID);
   if(el == null)
     return;

  cLeft = moveSingleVal(cLeft, nLeft, fLeft);
  cTop = moveSingleVal(cTop, nTop, fTop);
  cWidth = moveSingleVal(cWidth, nWidth, fWidth);
  cHeight = moveSingleVal(cHeight, nHeight, fHeight);

  el.style.left = Math.round(cLeft) + 'px';
  el.style.top = Math.round(cTop) + 'px';
  el.style.width = Math.round(cWidth) + 'px';
  el.style.height = Math.round(cHeight) + 'px';
 
  if(cLeft == nLeft && cTop == nTop && cHeight == nHeight
    && cWidth == nWidth)
  {
    if(callback != null)
      callback();
    return;
  }
   
  setTimeout( 'doFrame("'+eID+'",'+cLeft+','+nLeft+','+fLeft+','
    +cTop+','+nTop+','+fTop+','+cWidth+','+nWidth+','+fWidth+','
    +cHeight+','+nHeight+','+fHeight+','+callback+')', 40);
}

function moveSingleVal(currentVal, finalVal, frameAmt)
{
  if(frameAmt == 0 || currentVal == finalVal)
    return finalVal;
 
  currentVal += frameAmt;
  if((frameAmt> 0 && currentVal>= finalVal)
    || (frameAmt <0 && currentVal <= finalVal))
  {
    return finalVal;
  }
  return currentVal;
}
