/*
 * Copyright (c) 2008, Aleajecta
 * All rights reserved.
 * 
 * The Service and any necessary software used in connection with the 
 * Service ("Software") contain proprietary and confidential information 
 * that is protected by applicable intellectual property and other laws.
 * You agree not to modify, rent, lease, loan, sell, distribute or create
 * derivative works based on the Service or the Software, in whole or in part.
 */
var ELEInputDefault = [];
var keyPressed = '';
var TimeWrapper = {};
var BrowserId = 0;
var BROWSER_MOZ = 0;
var BROWSER_IE6 = 1;
var BROWSER_IE78 = 2;
var BROWSER_NS = 4;
var BROWSER_SAF = 8;
var BROWSER_OP = 16;
var BROWSER_CHR = 32;
//alert(navigator.userAgent);
if(navigator.userAgent.indexOf('Firefox/') != -1) //Mozzila/Firefox
    BrowserId = BROWSER_MOZ;
else if(navigator.userAgent.indexOf('MSIE 7') != -1 || navigator.userAgent.indexOf('MSIE 8') != -1) //IE 7-8
    BrowserId = BROWSER_IE78;
else if(navigator.userAgent.indexOf('MSIE 6') != -1) //IE 6
    BrowserId = BROWSER_IE6;
else if(navigator.userAgent.indexOf('Netscape/') != -1) //Nescape
    BrowserId = BROWSER_NS; 
else if(navigator.userAgent.indexOf('Chrome/') != -1)
    BrowserId = BROWSER_CHR;
else if(navigator.userAgent.indexOf('Safari/') != -1)
    BrowserId = BROWSER_SAF;
else if(navigator.userAgent.indexOf('Opera/') != -1)
    BrowserId = BROWSER_OP;

function updateTime()
{
    var dateTime = new Date();
    var time;
    var r = dateTime.getSeconds(); //Resolution
    if(parseInt(TimeWrapper['s1']+TimeWrapper['s2']) != r)
    {
        time = r.toString();
        //Debug.add(time.length);
        if(time.length != 2)
            time = "0"+time;
        
        if(TimeWrapper['s1'].innerHTML != time.charAt(0))
        {
            TimeWrapper['s1'].innerHTML = time.charAt(0);
            MM.push(MM_COLOR, TimeWrapper['s1'].id, ["80%", 3, null,TimeWrapper['s1'], 0, false]);
            MM.push(MM_COLOR, TimeWrapper['s1'].id, ["70%", 6, null,TimeWrapper['s1'], 0, false]);
            MM.push(MM_COLOR, TimeWrapper['s1'].id, ["80%", 6, null,TimeWrapper['s1'], 0, false]);
            MM.push(MM_COLOR, TimeWrapper['s1'].id, ["100%", 3, null,TimeWrapper['s1'], 0, false]);
            r = dateTime.getMinutes();
            if(parseInt(TimeWrapper['m1']+""+TimeWrapper['m2']) != r)
            {
                time = r.toString();
                if(time.length != 2)
                    time = "0"+time;
                
                if(TimeWrapper['m1'].innerHTML != time.charAt(0))
                {
                    TimeWrapper['m1'].innerHTML = time.charAt(0);
                    MM.push(MM_COLOR, TimeWrapper['m1'].id, ["50%", 3, null,TimeWrapper['m1'], 0, false]);
                    MM.push(MM_COLOR, TimeWrapper['m1'].id, ["100%", 3, null,TimeWrapper['m1'], 0, false]);
                    
                    r = dateTime.getHours();
                    if(parseInt(TimeWrapper['h1']+""+TimeWrapper['h2']) != r)
                    {
                        time = r.toString();
                        
                        if(time.length != 2)
                            time = "0"+time;

                        if(TimeWrapper['h1'].innerHTML != time.charAt(0))
                        {
                            TimeWrapper['h1'].innerHTML = time.charAt(0);
                            MM.push(MM_COLOR, TimeWrapper['h1'].id, ["50%", 3, null,TimeWrapper['h1'], 0, false]);
                            MM.push(MM_COLOR, TimeWrapper['h1'].id, ["100%", 3, null,TimeWrapper['h1'], 0, false]);
                        }
                        if(TimeWrapper['h2'].innerHTML != time.charAt(1))
                        {
                            TimeWrapper['h2'].innerHTML = time.charAt(1);
                            MM.push(MM_COLOR, TimeWrapper['h2'].id, ["50%", 3, null,TimeWrapper['h2'], 0, false]);
                            MM.push(MM_COLOR, TimeWrapper['h2'].id, ["100%", 3, null,TimeWrapper['h2'], 0, false]);
                        }
                    }
                }
                
                if(TimeWrapper['m2'].innerHTML != time.charAt(1))
                {
                    TimeWrapper['m2'].innerHTML = time.charAt(1);
                    MM.push(MM_COLOR, TimeWrapper['m2'].id, ["50%", 3, null,TimeWrapper['m2'], 0, false]);
                    MM.push(MM_COLOR, TimeWrapper['m2'].id, ["100%", 3, null,TimeWrapper['m2'], 0, false]);
                }
            }
        }
        
        
        if(TimeWrapper['s2'].innerHTML != time.charAt(1))
        {
            TimeWrapper['s2'].innerHTML = time.charAt(1);
            MM.clear(MM_COLOR,TimeWrapper['s2'].id);
            MM.push(MM_COLOR, TimeWrapper['s2'].id, ["80%", 3, null,TimeWrapper['s2'], 0, false]);
            MM.push(MM_COLOR, TimeWrapper['s2'].id, ["60%", 6, null,TimeWrapper['s2'], 0, false]);
            MM.push(MM_COLOR, TimeWrapper['s2'].id, ["80%", 6, null,TimeWrapper['s2'], 0, false]);
            MM.push(MM_COLOR, TimeWrapper['s2'].id, ["100%", 3, null,TimeWrapper['s2'], 0, false]);
        }
    }
    //TimeWrapper['mm'].innerHTML = dateTime.getMilliseconds() < 10 ? "0"+dateTime.getHours() : dateTime.getHours();
}
function Initialize()
{
	Debug.init();
	//pour le fun
    TimeWrapper['h1'] = document.getElementById("hourD1");
	TimeWrapper['m1'] = document.getElementById("minuteD1");
    TimeWrapper['h2'] = document.getElementById("hourD2");
	TimeWrapper['m2'] = document.getElementById("minuteD2");
	TimeWrapper['s1'] = document.getElementById("secondD1");
	TimeWrapper['s2'] = document.getElementById("secondD2");
	//TimeWrapper['mm'] = document.getElementById("milliemD");
    updateTime();
    document.getElementById('timeWrapper').style.visibility = "visible";
    setInterval('updateTime()',1000);
	
	//keep Mouse Coord
	document.onmousemove  = function(event)
	{
		var event = window.event ? window.event : event;
		Mouse.coord['x'] = event.clientX;
		Mouse.coord['y'] = event.clientY;
	};
	document.onmouseup = function(event)
	{
	    Mouse.down = false;
	}
	document.onmousedown = function(event)
	{
	    Mouse.down = true;
	}
	document.onkeydown = function(event)
	{
        var event = window.event ? window.event : event;
        keyPressed = (event.keyCode | event.charCode);
	}
	document.onkeyup = function()
	{
	    keyPressed = '';
	}
	
	Mouse.SetScrollTarget(document.getElementById('contentWrapper'));
	if(window.addEventListener) //Only Firefox,Netscape
	{
		window.addEventListener('DOMMouseScroll', Mouse.wheel, false);
		//parent.window.addEventListener('DOMMouseScroll', wheel, false);
	}
	else//Moron, Opera 
	    window.onmousewheel = document.onmousewheel = Mouse.wheel;

    
	var pMotion = "MM.push(MM_ALPHA, 'contentWrapper', [1.0, 0.1, function(owner){MM.push(MM_COLOR, owner.id, ['50%', 4, null,owner, 1, false]);MM.push(MM_COLOR, owner.id, ['100%', 2, null,owner, 1, false]);},document.getElementById('contentWrapper'), 0, false]);";	
    //Debug.add(BrowserId);
    if(BrowserId != BROWSER_IE78 && BrowserId != BROWSER_IE6)//IE Check
        setTimeout( pMotion, 1);
                

    setInterval('MM.update()',20);

    var links;
    var linkNames = ['a','input','textarea','span','p','li','div','img'];
    for(var itr = 0; itr < linkNames.length; itr++)
    {
        links = document.getElementsByTagName(linkNames[itr]);

        for (var ctr = 0; ctr < links.length; ctr++)
        {       
            if (links[ctr].id == "") 
                links[ctr].id = "mm_id" + itr+ctr;
                
            if(links[ctr].className.indexOf("noInit") != -1)
                continue;
                            
            var RGB = colorToArray(links[ctr].style.color);
            
            if (window.location.href.indexOf("info=0") !=-1 || window.location.href.indexOf("info") ==-1
                || (links[ctr].parentNode && links[ctr].parentNode.id == "subButtonWrapper" && window.location.href.indexOf("subInfo") == -1)
                || (links[ctr].parentNode && links[ctr].parentNode.id == "contentWrapper"))
            {
                if (links[ctr].style.color != "" && (typeof links[ctr].style.color) != "undefined")
                {
                    if (RGB[0] == RGB[1] && RGB[1] == RGB[2])
                    {
                        var s = "MM.push(MM_COLOR, '"+links[ctr].id+"', ['50%', 8, null,document.getElementById('"+links[ctr].id+"'), "+(ctr>5?ctr-5:ctr)*150+", false]);";
                        s += "MM.push(MM_COLOR, '"+links[ctr].id+"', ['100%', 5, null,document.getElementById('"+links[ctr].id+"'), 100, false]);";
                        setTimeout(s,1);
                    }
                    else
                    {
                        var s = "MM.push(MM_COLOR, '"+links[ctr].id+"', ['200%', 3, null,document.getElementById('"+links[ctr].id+"'), 1500, false]);";
                            s += "MM.push(MM_COLOR, '"+links[ctr].id+"', ['100%', 1, null,document.getElementById('"+links[ctr].id+"'), 0, false]);";
                        setTimeout(s,1);  
                    }
                }
            }
            
            if (1)
            {
                if (links[ctr].style.color != "" && (typeof links[ctr].style.color) != "undefined")
                {
                    if (RGB[0] == RGB[1] && RGB[1] == RGB[2])
                    {
                        links[ctr].onmouseover = function(owner)
                        {
                            MM.clear(MM_COLOR,this.id);
                            MM.push(MM_COLOR, this.id, ['40%', 5, null,this, 1, false]);
                        };
                        links[ctr].onmouseout = function(owner)
                        {
                            MM.push(MM_COLOR, this.id, ['100%', 5, null,this, 10, false]);
                        };
                    }
                    else
                    {
                        links[ctr].onmouseover = function()
                        {
                            MM.clear(MM_COLOR,this.id);
                            MM.push(MM_COLOR, this.id, ['200%', 2, null,this, 1, false]);
                        };
                        links[ctr].onmouseout = function()
                        {
                            MM.push(MM_COLOR, this.id, ['100%', 1, null,this, 10, false]);
                        };
                    }
                }
            }
            
            if (linkNames[itr] == 'img')
            {
	            if(!links[ctr].style.opacity)
	            {
	                links[ctr].style.opacity = 0.1;
	                links[ctr].style.filter = "Alpha(opacity=10)";
	            }

                links[ctr].onmouseover=function()
                {
                    MM.clear(MM_ALPHA,this.id);
                    if(parseFloat(this.style.opacity) < 0.5)
                        MM.push(MM_ALPHA,this.id,[0.5,0.02,null,this,0,false]);
                    MM.push(MM_ALPHA,this.id,[0.8,0.04,null,this,0,false]);
                }
                links[ctr].onmouseout=function()
                {
                    MM.push(MM_ALPHA,this.id,[0.5,0.03,null,this,0,false]);
                    MM.push(MM_ALPHA,this.id,[0.3,0.04,null,this,0,false]);
                }
	                
                var s = "MM.push(MM_ALPHA, '"+links[ctr].id+"', [0.7, 0.05, null,document.getElementById('"+links[ctr].id+"'), 300, false]);";
                s += "MM.push(MM_ALPHA, '"+links[ctr].id+"', [0.4, 0.02, null,document.getElementById('"+links[ctr].id+"'), 0, false]);";
                setTimeout(s,1);
                
            }
                
            if (links[ctr].className.indexOf("initColor") != -1)
            {
                if (links[ctr].style.color != "" && (typeof links[ctr].style.color) != "undefined")
                {
                    if (RGB[0] == RGB[1] && RGB[1] == RGB[2])
                    {
                        links[ctr].onmouseover = function(owner)
                        {
                            MM.clear(MM_COLOR,this.id);
                            MM.push(MM_COLOR, this.id, ['40%', 5, null,this, 1, false]);
                        };
                        links[ctr].onmouseout = function(owner)
                        {
                            MM.push(MM_COLOR, this.id, ['100%', 5, null,this, 10, false]);
                        };
                    }
                    else
                    {                
                        links[ctr].onmouseover = function()
                        {
                            MM.clear(MM_COLOR,this.id);
                            MM.push(MM_COLOR, this.id, ['200%', 2, null,this, 1, false]);
                        };
                        links[ctr].onmouseout = function()
                        {
                            MM.push(MM_COLOR, this.id, ['100%', 1, null,this, 10, false]);
                        };
                    }
                }
            }
            
            if (links[ctr].className.indexOf("initFollow") != -1)
            {
	            links[ctr].onmousedown=function()
	            {
	                MM.clear(MM_FOLLOW,this.id);
	                MM.push(MM_FOLLOW,this.id,[Mouse.coord['y'] -  this.offsetTop,Mouse.coord['x'] - this.offsetLeft,null,this,0,false]);
	                return false;
	            }
	            links[ctr].onmouseup=function()
	            {
	                MM.clear(MM_FOLLOW,this.id);
	            }
            }
            
            if (links[ctr].className.indexOf("initAlpha") != -1)
            {
		        
                links[ctr].onmouseover = function()
                {
                    MM.clear(MM_ALPHA,this.id);
                    MM.push(MM_ALPHA, this.id, ['0.7', 0.05, null,this, 0, false]);
                };
                links[ctr].onmouseout = function()
                {
                    MM.push(MM_ALPHA, this.id, ['0.3', 0.02, null,this, 0, false]);
                }; 
            }
                
            if (links[ctr].className.indexOf("initLogo") != -1)
            {              
	            links[ctr].onmouseover=function()
	            {
	                var imgs = this.getElementsByTagName("img");
	                var spans = this.getElementsByTagName("span");
	                
	                for (var itr = 0; itr < imgs.length; itr++)
	                {
	                    MM.clear(MM_ALPHA,imgs[itr].id);
	                    if(parseFloat(imgs[itr].style.opacity) < 0.5)
	                        MM.push(MM_ALPHA,imgs[itr].id,[0.5,0.02,null,imgs[itr],0,false]);
	                    MM.push(MM_ALPHA,imgs[itr].id,[0.8,0.04,null,imgs[itr],0,false]);
	                }
	                for (var itr = 0; itr < spans.length; itr++)
	                {
                        MM.clear(MM_COLOR,spans[itr].id);
                        MM.push(MM_COLOR, spans[itr].id, ['40%', 5, null,spans[itr], 1, false]);
	                }	                
	            }
	            
	            links[ctr].onmouseout=function()
	            {
	                var imgs = this.getElementsByTagName("img");
	                var spans = this.getElementsByTagName("span");
	                
	                for (var itr = 0; itr < imgs.length; itr++)
	                {
	                    MM.push(MM_ALPHA,imgs[itr].id,[0.5,0.03,null,imgs[itr],0,false]);
	                    MM.push(MM_ALPHA,imgs[itr].id,[0.3,0.04,null,imgs[itr],0,false]);
	                }
	                for (var itr = 0; itr < spans.length; itr++)
	                {    
                        MM.push(MM_COLOR, spans[itr].id, ['100%', 5, null,spans[itr], 10, false]);
                    }
	            }	       
            }
                            
            if (links[ctr].className.indexOf("initResize") != -1)
            {  
                links[ctr].onmousedown = function (event)
                {
		            Mouse.down = true;
		            if(window.event)
		            {
		                window.event.cancelBubble = true;
		            }
		            else
		            {
		                event.cancelBubble = true;
		                event.stopPropagation();
		            }
	                MM.push(MM_ALPHA, 'browserBlur', [0.3, 0.25, null,document.getElementById('browserBlur'), 0, false]);
	                document.getElementById('browserBlur').style.display = 'block';
		            
		            var offset = MM.AbsoluteOffset(document.getElementById('browserWrapper'));
		            MM.push(MM_SIZE,'browserWrapper',[offset[0]+document.getElementById('browserWrapper').offsetHeight-Mouse.coord['y'],
		            offset[1]+document.getElementById('browserWrapper').offsetWidth-Mouse.coord['x'],
		            100,100,'px',true,function(){MM.push(MM_ALPHA, 'browserBlur', [0.0, 0.04, function(owner){owner.style.display = 'none';},document.getElementById('browserBlur'), 0, false])}
		            ,document.getElementById('browserWrapper'),0,false]);
		            
		            return false;
		        }
            }
                            
            if (links[ctr].className.indexOf("initMaximize") != -1)
            {  
                links[ctr].onmousedown = function (event)
                {
		            Mouse.down = true;
		            if(window.event)
		            {
		                window.event.cancelBubble = true;
		            }
		            else
		            {
		                event.cancelBubble = true;
		                event.stopPropagation();
		            }
	                //MM.push(MM_ALPHA, 'browserBlur', [0.3, 0.25, null,document.getElementById('browserBlur'), 0, false]);
	                //document.getElementById('browserBlur').style.display = 'block';
		            
		            MM.push
		            (
		                MM_SIZE,'browserWrapper',
		                [100 - 30/document.body.clientHeight * 100, 100 - 30/document.body.clientWidth * 100, 15, 15, '%', false, 
		                    function()
		                    {
		                    }, document.getElementById('browserWrapper'), 0, false
		                ]
		            );
		            
		            MM.push(MM_DESTINATION, 'browserWrapper', [0, 0, 0, 0, 200, 200, 'px', null, document.getElementById('browserWrapper'), 0, false]);
		            //DH_TOP = 0, DH_LEFT = 1, DH_BOTTOM = 2, DH_RIGHT = 3, DH_TLSPEED = 4, DH_BRSPEED = 5, DH_TYPE = 6, DH_FINAL=7,DH_OWNER = 8, DH_WAIT_TIME = 9, DH_PAUSE = 10; // DestinationHolder
		            return false;
		        }
            }
            
            if (links[ctr].className.indexOf("initDot") != -1)
            {
		        
                links[ctr].onmouseover = function()
                {
                    MM.clear(MM_ALPHA,this.id);
                    MM.push(MM_ALPHA, this.id, ['0.4', 0.05, null,this, 0, false]);
                };
                links[ctr].onmouseout = function()
                {
                    MM.push(MM_ALPHA, this.id, ['0.1', 0.02, null,this, 0, false]);
                }; 
            }
                
            if (links[ctr].className.indexOf("initContent") != -1 && window.location.href.indexOf("info=5") != -1&& window.location.href.indexOf("subInfo=0") != -1)
            {
                links[ctr].onmouseover = function()
                {
                    MM.clear(MM_COLOR,this.id);
                    MM.push(MM_COLOR, this.id, ['50%', 2, null,this, 0, false]);
                };
                links[ctr].onmouseout = function()
                {
                    MM.push(MM_COLOR, this.id, ['100%', 4,null, this, 200, false]);
                };
            }
                
            if (links[ctr].className.indexOf("initContactForm") != -1)
            {              
                if(BrowserId != BROWSER_IE78 && BrowserId != BROWSER_IE6)
					continue;
				links[ctr].onmouseover = function()
                {
                    MM.clear(MM_COLOR,this.id);
                    MM.push(MM_COLOR, this.id, ['#111111', 3, null,this, 0, false]);
                    MM.clear(MM_BACKGROUNDCOLOR,this.id);
                    
                    MM.push(MM_BACKGROUNDCOLOR, this.id, ['#fafafa',  0.25, null,this, 0, false]);
                };
                links[ctr].onmouseout = function()
                {
                    MM.push(MM_COLOR, this.id, ['#aaaaaa',  1,null, this, 0, false]);
                    MM.clear(MM_BACKGROUNDCOLOR,this.id);
                    MM.push(MM_BACKGROUNDCOLOR, this.id, ['#ffffff',  0.25,null, this, 0, false]);
                };
            }
            
            if (linkNames[itr] == 'a')
            {
                if (links[ctr].href.indexOf("aleajecta.com") == -1 )
                {
                    if (BrowserId != BROWSER_IE6)
                        links[ctr].onclick = function() 
                        {
                            if (keyPressed != 16 && keyPressed != 17)
                            {
                                document.getElementById("browserFrame").src = this.href;
                                document.getElementById("browserWrapper").style.display = "block";
                                //setTimeout(InitFrame,100);
                                return false;
                            }
                        };
                    else
                        links[ctr].onclick = function() {
                            window.open(this.href, "_blank");
                            return false;
                        };
                }
            }
            
            if(linkNames[itr] != 'p' && (typeof links[ctr].onmousedown) == "undefined")   
                links[ctr].onmousedown = function() { return false; };
        }
    }
    //<iframe frameborder="0" id="browserFrame" src="" scrolling="yes" style="width: 100%; height: 100%; z-index: 930; background-color: #FFFFFF;"></iframe>
    var iframe = document.createElement("iframe");
    iframe.id = "browserFrame";
    iframe.frameBorder = "0";
    iframe.src = "";
    iframe.scrolling = "yes";
    iframe.style.width = "100%";
    iframe.style.height = "100%";
    iframe.style.zIndex = "930";
    iframe.style.backgroundColor = "#FFFFFF";
    document.getElementById("browserWrapper").appendChild(iframe);
    MM.CenterAbsolute(true,true,document.getElementById("browserWrapper"),document.body);
}

function colorToArray(_color) 
{
    var RGB = [];
    
    if (_color.indexOf("rgb") != -1)
    {
        _color = _color.replace(/[RGB\(\)]/ig,"");
        RGB = _color.split(",");
        if (RGB.length != 3) 
            return;        
        RGB[0] = parseInt(RGB[0]);
        RGB[1] = parseInt(RGB[1]);
        RGB[2] = parseInt(RGB[2]);
    }
    else if (_color.indexOf("#") != -1 && _color.length == 7)
    {
        RGB[0] = parseInt(_color.substr(1,2), 16);
        RGB[1] = parseInt(_color.substr(3,2), 16);
        RGB[2] = parseInt(_color.substr(5,2), 16);
    }
    
    return RGB;
}

//***************EMAIL*******************
function clearDefaultText(ele)
{
    if (!ELEInputDefault[ele.id] || ELEInputDefault[ele.id] == "undefined")
        ELEInputDefault[ele.id] = ele.value;
    if (ELEInputDefault[ele.id] == ele.value)
        ele.value = "";
}
function validateEmail(ele)
{
    var errorEmail = document.getElementById("errorEmail");
    var errorColor = [];

    if (ele.value == "")
    {
        ele.value = ELEInputDefault[ele.id];
        MM.clear(MM_COLOR,"errorEmail");
        MM.push(MM_COLOR, "errorEmail", ["rgb(255, 255, 255)", 20, null,errorEmail, 0, false]);
        errorEmail.onmouseout = null;
        errorEmail.onmouseover = null;
        setTimeout("document.getElementById('errorEmail').style.display = 'none'", 250);
        return false;
    }
    else
    {
        var reg = new RegExp(/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/);
        if (ele.value.match(reg))
        {
            MM.clear(MM_COLOR,"errorEmail");
            MM.push(MM_COLOR, "errorEmail", ["rgb(255, 255, 255)", 20, null,errorEmail, 0, false]);
            errorEmail.onmouseout = null;
            errorEmail.onmouseover = null;
            setTimeout("document.getElementById('errorEmail').style.display = 'none'", 250);
            return true;
        }
        else
        {
            errorEmail.style.display = "inline";
            MM.clear(MM_COLOR,"errorEmail");
            MM.push(MM_COLOR, "errorEmail", ["rgb(239, 100, 89)", 3, null,errorEmail, 0, false]);
            MM.push(MM_COLOR, "errorEmail", ["rgb(255, 255, 255)", 3, null,errorEmail, 3000, false]);
            errorEmail.onmouseout = function() { MM.clear(MM_COLOR,"errorEmail"); MM.push(MM_COLOR, this.id, ["rgb(255, 255, 255)", 3, null,this, 0, false]); };
            errorEmail.onmouseover = function() { MM.clear(MM_COLOR,"errorEmail"); MM.push(MM_COLOR, this.id, ["rgb(239, 100, 89)", 3, null,this, 0, false]); };
            /*errorEmail.onmouseover = function() { startColorPlay(this.id, "rgb(223, 67, 55)", 2) };
            errorEmail.onmouseout = function() { startColorPlay(this.id, "rgb(239, 100, 89)", 2) };*/
            return false;
        }
    }
}

function validateSubject(ele)
{
    if (ele.value == "")
        ele.value = ELEInputDefault[ele.id];
}

function validateMessage(ele)
{
    if (ele.value == "")
        ele.value = ELEInputDefault[ele.id];
}


function submitForm()
{
    email = document.getElementById("email");
    if (!email)
        return false;

    return validateEmail(email);
}


/*******************Motion Master***********************/
/* PRIORITY:008 */
/**
 * @author Greenseed
 */

//IMPORTANT Keep Pause Value at The END.
var MM_DESTINATION = 0, MM_SIZE = 1, MM_FONT_SIZE = 2, MM_ALPHA = 3, MM_FOLLOW = 4, MM_COLOR = 5, MM_BACKGROUNDCOLOR; // Motion Type

var DH_TOP = 0, DH_LEFT = 1, DH_BOTTOM = 2, DH_RIGHT = 3, DH_TLSPEED = 4, DH_BRSPEED = 5, DH_TYPE = 6, DH_FINAL=7,DH_OWNER = 8, DH_WAIT_TIME = 9, DH_PAUSE = 10; // DestinationHolder
var SH_HEIGHT = 0, SH_WIDTH = 1, SH_HSPEED = 2, SH_WSPEED = 3, SH_TYPE = 4,SH_MOUSE=5, SH_FINAL = 6,SH_OWNER = 7, SH_WAIT_TIME = 8, SH_PAUSE = 9; // SizeHolder
var SFH_SIZE = 0, SFH_SPEED = 1, SFH_TYPE = 2, SFH_FINAL = 3,SFH_OWNER = 4, SFH_WAIT_TIME = 5, SFH_PAUSE = 6; // FontSizeHolder    
var AH_END_ALPHA = 0, AH_SPEED = 1, AH_FINAL =2, AH_OWNER = 3, AH_WAIT_TIME = 4, AH_PAUSE = 5; // AlphaHolder 
var FH_OFFSET_TOP = 0, FH_OFFSET_LEFT = 1, FH_FINAL=2,FH_OWNER = 3, FH_WAIT_TIME = 4, FH_PAUSE = 5; // FollowHolder  
var CH_END_COLOR = 0, CH_SPEED = 1, CH_FINAL = 2, CH_OWNER = 3, CH_WAIT_TIME = 4, CH_PAUSE = 5; // ColorHolder 
var BCH_END_COLOR = 0, BCH_SPEED = 1, BCH_FINAL = 2, BCH_OWNER = 3, BCH_WAIT_TIME = 4, BCH_PAUSE = 5; // BackgroundColorHolder 

function MM(){}(function()
{
    var DestinationHolder = {};
    var SizeHolder = {};
    var FontSizeHolder = {};
    var AlphaHolder = {};
    var FollowHolder = {};
    var ColorHolder = {},ColorDefault = {},ColorCurrent = {};
    var BackgroundColorHolder = {},BackgroundColorDefault = {},BackgroundColorCurrent = {};

    var Timer = new Date().getTime(); //Make this Global
    var Diff = 0;

    var Move = function(ownerName)
    {
        var DH = DestinationHolder[ownerName][0];
        
        if(DH[DH_OWNER].style.bottom != "")
            DH[DH_OWNER].style.bottom = "";
        
        if(DH[DH_OWNER].style.right != "")
            DH[DH_OWNER].style.right = "";

    	var Top = parseFloat(DH[DH_OWNER].style.top);
        var Left = parseFloat(DH[DH_OWNER].style.left);
        
        var diff = Math.abs(DH[DH_TOP] - Top);
        if (diff < Math.abs(DH[DH_LEFT] - Left))
            diff = Math.abs(DH[DH_LEFT] - Left);
        
        if (diff == 0 || diff < DH[DH_TLSPEED])
        {
            DH[DH_OWNER].style.top = DH[DH_TOP].toFixed(2)+DH[DH_TYPE];
            DH[DH_OWNER].style.left = DH[DH_LEFT].toFixed(2)+DH[DH_TYPE];
            return false;
        }
        else
        {
            if (Top < DH[DH_TOP])
                DH[DH_OWNER].style.top = (Top + DH[DH_TLSPEED]*(DH[DH_TOP] - Top)/diff).toFixed(2)+DH[DH_TYPE];
            else
                DH[DH_OWNER].style.top = (Top - DH[DH_TLSPEED]*(Top - DH[DH_TOP])/diff).toFixed(2)+DH[DH_TYPE];
                
            if (Left < DH[DH_LEFT])
                DH[DH_OWNER].style.left = (Left + DH[DH_TLSPEED]*(DH[DH_LEFT] - Left)/diff).toFixed(2)+DH[DH_TYPE];
            else
                DH[DH_OWNER].style.left = (Left - DH[DH_TLSPEED]*(Left - DH[DH_LEFT])/diff).toFixed(2)+DH[DH_TYPE];
                
            return true;
        }
    }
    
    var Resize = function(ownerName)
    {
        var SH = SizeHolder[ownerName][0];

        var Height, Width;
        if (SH[SH_TYPE] == "px")
        {
            Height = SH[SH_OWNER].offsetHeight;
            Width = SH[SH_OWNER].offsetWidth;
        }
        else
        {
            Height = parseFloat(SH[SH_OWNER].style.height);
            Width = parseFloat(SH[SH_OWNER].style.width);
        }
        var nH,nW,nT,nL;
        
        if(SH[SH_MOUSE])
        {   //resize mandatory type PX
            var offSet = MM.AbsoluteOffset(SH[SH_OWNER]);

            //Debug.add("start:"+SH[SH_HEIGHT]);
            //Debug.add("offset:"+offSet[0]);
            //Debug.add("client:"+document.body.clientHeight);
            //Debug.add("mouse:"+Mouse.coord['y']);
            
            nH = (Mouse.coord['y']-SH[SH_HEIGHT]-offSet[0]-15);
            nW = (Mouse.coord['x']-SH[SH_WIDTH]-offSet[1]-15);
            //nH = (Mouse.coord['y']-SH[SH_HEIGHT]-15-offSet[0]  )/document.body.clientHeight  * 100;  
            //nW = (Mouse.coord['x']-SH[SH_WIDTH]-15-offSet[1] )/document.body.clientWidth * 100; 
            
            /*if (nH < 0)
            {
                nH = Math.abs(nH);
                nT = (parseFloat(SH[SH_OWNER].style.top) + (Height-nH)/100 * document.body.clientHeight).toFixed(2) + "px";
            }
            if (nW < 0)
            {
                nW = Math.abs(nW);
                nL = (parseFloat(SH[SH_OWNER].style.left) + (Width-nW)/100 * document.body.clientWidth).toFixed(2) + "px";
            }*/
            
            //Debug.add("offSet[0]:"+offSet[0]+"\noffSet[1]:"+offSet[1]);
            //SH[SH_HEIGHT] = Mouse.coord['y'];
            //SH[SH_WIDTH]= Mouse.coord['x'];
          //window.screen.height 
        }
        else
        {
            nH = SH[SH_HEIGHT];
            nW = SH[SH_WIDTH]; 
        }
        
        var End = 2;
        if(Height > nH)
        {
            Height -= SH[SH_HSPEED];
            if (Height < nH) 
            {
                SH[SH_OWNER].style.height = nH.toFixed(2) + SH[SH_TYPE];
                --End;
            }
            else 
                SH[SH_OWNER].style.height = Height.toFixed(2) + SH[SH_TYPE];      
                
        }
        else if(Height < nH)
        {
            Height += SH[SH_HSPEED];
            if(Height > nH)
            {
                SH[SH_OWNER].style.height = nH.toFixed(2) + SH[SH_TYPE];
                --End;
            }
            else
                SH[SH_OWNER].style.height = Height.toFixed(2) + SH[SH_TYPE];     
        }
        else
            --End;

        if(Width > nW)
        {
            Width -= SH[SH_WSPEED];
            if (Width < nW) 
            {
                SH[SH_OWNER].style.width = nW.toFixed(2) + SH[SH_TYPE];
                --End;
            }
            else 
                SH[SH_OWNER].style.width = Width.toFixed(2) + SH[SH_TYPE];      
        }
        else if(Width < nW)
        {
            Width += SH[SH_WSPEED];
            if (Width > nW) 
            {
                SH[SH_OWNER].style.width = nW.toFixed(2) + SH[SH_TYPE];
                --End;
            }
            else 
                SH[SH_OWNER].style.width = Width.toFixed(2) + SH[SH_TYPE];     
        }
        else
            --End;
            
        //SH[SH_OWNER].style.top = nT;
        //SH[SH_OWNER].style.left = nL;
            
        //MM.CenterAbsolute(true,true,SH[SH_OWNER]);
        
        if ((!End && !SH[SH_MOUSE]) || (SH[SH_MOUSE] && !Mouse.down)) 
            return false;

        return true;
    };
    var ResizeFont = function(ownerName)
    {
        var SFH = FontSizeHolder[ownerName][0];
        var FontSize = parseFloat(SFH[SFH_OWNER].style.fontSize);
        //(FontSize);
        if(FontSize == "NaN")
            FontSize = 1.0;
        //alert(FontSize);
        var End = 1;
        if(FontSize > SFH[SFH_SIZE])
        {
            FontSize -= SFH[SFH_SPEED];
            if (FontSize < SFH[SFH_SIZE]) 
            {
                SFH[SFH_OWNER].style.fontSize = SFH[SFH_SIZE].toFixed(2) + SFH[SFH_TYPE];
                --End;
            }
            else 
                SFH[SFH_OWNER].style.fontSize = FontSize.toFixed(2) + SFH[SFH_TYPE];      
        }
        else if(FontSize < SFH[SFH_SIZE])
        {
            FontSize += SFH[SFH_SPEED];
            if(FontSize > SFH[SFH_SIZE])
            {
                SFH[SFH_OWNER].style.fontSize = SFH[SFH_SIZE].toFixed(2) + SFH[SFH_TYPE];
                --End;
            }
            else
                SFH[SFH_OWNER].style.fontSize = FontSize.toFixed(2) + SFH[SFH_TYPE];     
        }
        else
            --End;
        
        if (!SH[SH_MOUSE])
          MM.centerAbsolute(true,true,SFH[SFH_OWNER]);
        
        if (!End) 
            return false;

        return true;
    };
    var AlphaPlay = function(ownerName)
    { 
        var AH = AlphaHolder[ownerName][0];
        var current = parseFloat(AH[AH_OWNER].style.opacity);
        
        //alert(AH[AH_OWNER].style.opacity);
        if (Math.abs(AH[AH_END_ALPHA] - current) <= AH[AH_SPEED])
        {
            AH[AH_OWNER].style.opacity = AH[AH_END_ALPHA];
            AH[AH_OWNER].style.filter = "Alpha(opacity="+parseInt(AH[AH_END_ALPHA]*100)+")";
            //AH[AH_OWNER].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+parseInt(AH[AH_END_ALPHA]*100)+")";
            return false;
        }
        else
        {
            if (current > AH[AH_END_ALPHA])
                current -= AH[AH_SPEED];
            else
                current += AH[AH_SPEED];
                
            AH[AH_OWNER].style.opacity = current.toFixed(2);
            AH[AH_OWNER].style.filter = "Alpha(opacity="+parseInt(current*100)+")";
            //AH[AH_OWNER].style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity="+parseInt(current*100)+")";
            return true;
        }
    };
    var Follow = function(ownerName)
    { 
        var FH = FollowHolder[ownerName][0];
        if(FH[FH_OWNER].style.bottom != "")
            FH[FH_OWNER].style.bottom = "";
        
        if(FH[FH_OWNER].style.right != "")
            FH[FH_OWNER].style.right = "";
            
        FH[FH_OWNER].style.top = (Mouse.coord['y'] - FH[FH_OFFSET_TOP]).toFixed(0) + "px";
        FH[FH_OWNER].style.left =  (Mouse.coord['x'] - FH[FH_OFFSET_LEFT]).toFixed(0) + "px";

        return true;
    };
    var SetColorPlay = function(ownerName,index)
    {        
        var CH = ColorHolder[ownerName][index-1];
        if(CH[CH_OWNER].style.color.indexOf("inherit") != -1)
        {
            CH[CH_OWNER].style.color = CH[CH_OWNER].parentNode.style.color;
        }
        if(!ColorCurrent[ownerName] || ColorCurrent[ownerName] == "undefined")
        {
            ColorCurrent[ownerName] = colorToArray(CH[CH_OWNER].style.color);
        }
        if(!ColorDefault[ownerName] || ColorDefault[ownerName] == "undefined")
        {
            if (CH[CH_END_COLOR].indexOf("%") != -1)
                ColorDefault[ownerName] =  colorToArray(CH[CH_OWNER].style.color);
            else
               ColorDefault[ownerName] =  colorToArray(CH[CH_END_COLOR]); 
        }
        if (CH[CH_END_COLOR].indexOf("%") != -1)
        {
            var ratio = CH[CH_END_COLOR];
            CH[CH_END_COLOR] = [];
             
            ratio = parseFloat(ratio.replace("%",""))/100.0;
                
            if (ColorDefault[ownerName][0] > ColorDefault[ownerName][1] && ColorDefault[ownerName][0] > ColorDefault[ownerName][2])
            {
                if (Math.floor(ColorDefault[ownerName][0] * ratio) > 255)
                   ratio = 255/ColorDefault[ownerName][0];
            }
            else if (ColorDefault[ownerName][1] > ColorDefault[ownerName][0] && ColorDefault[ownerName][1] > ColorDefault[ownerName][2])
            {
                if (Math.floor(ColorDefault[ownerName][1] * ratio) > 255)
                   ratio = 255/ColorDefault[ownerName][1];
            }
            else
            {
                if (Math.floor(ColorDefault[ownerName][2] * ratio) > 255)
                   ratio = 255/ColorDefault[ownerName][2];
            }
            
            CH[CH_END_COLOR][0] = Math.floor(ColorDefault[ownerName][0] * ratio);
            CH[CH_END_COLOR][1] = Math.floor(ColorDefault[ownerName][1] * ratio);
            CH[CH_END_COLOR][2] = Math.floor(ColorDefault[ownerName][2] * ratio);
        }
        else
        {
            CH[CH_END_COLOR] = colorToArray(CH[CH_END_COLOR]);
        }
        //CH[2999999].bob = 2;
    }
    var ColorPlay = function(ownerName)
    { 
        var CH = ColorHolder[ownerName][0];

        if (CH[CH_SPEED] < 0) 
            CH[CH_SPEED] = Math.abs(CH[CH_SPEED]);
            
        /*if (!ColorCurrent[ownerName])
            ColorCurrent[ownerName] = colorToArray(CH[CH_OWNER].style.color);*/
        
        var diff = Math.abs(CH[CH_END_COLOR][0] - ColorCurrent[ownerName][0]);
        if (diff < Math.abs(CH[CH_END_COLOR][1] - ColorCurrent[ownerName][1]))
            diff = Math.abs(CH[CH_END_COLOR][1] - ColorCurrent[ownerName][1]);
        if (diff < Math.abs(CH[CH_END_COLOR][2] - ColorCurrent[ownerName][2]))
            diff = Math.abs(CH[CH_END_COLOR][2] - ColorCurrent[ownerName][2]);
            
        
        if (diff == 0 || diff < CH[CH_SPEED])
        {
            ColorCurrent[ownerName][0] = CH[CH_END_COLOR][0];
            ColorCurrent[ownerName][1] = CH[CH_END_COLOR][1];
            ColorCurrent[ownerName][2] = CH[CH_END_COLOR][2];
            CH[CH_OWNER].style.color = "rgb(" + parseInt(ColorCurrent[ownerName][0]) + ", " + parseInt(ColorCurrent[ownerName][1]) + ", " + parseInt(ColorCurrent[ownerName][2]) + ")";
            return false;
        }
        else
        {
            if (ColorCurrent[ownerName][0] < CH[CH_END_COLOR][0])
                ColorCurrent[ownerName][0] = ColorCurrent[ownerName][0] + CH[CH_SPEED]*(CH[CH_END_COLOR][0] - ColorCurrent[ownerName][0])/diff;
            else
                ColorCurrent[ownerName][0] = ColorCurrent[ownerName][0] - CH[CH_SPEED]*(ColorCurrent[ownerName][0] - CH[CH_END_COLOR][0])/diff;

            if (ColorCurrent[ownerName][1] < CH[CH_END_COLOR][1])
                ColorCurrent[ownerName][1] = ColorCurrent[ownerName][1] + CH[CH_SPEED]*(CH[CH_END_COLOR][1] - ColorCurrent[ownerName][1])/diff;
            else
                ColorCurrent[ownerName][1] = ColorCurrent[ownerName][1] - CH[CH_SPEED]*(ColorCurrent[ownerName][1] - CH[CH_END_COLOR][1])/diff;
                
            if (ColorCurrent[ownerName][2] < CH[CH_END_COLOR][2])
                ColorCurrent[ownerName][2] = ColorCurrent[ownerName][2] + CH[CH_SPEED]*(CH[CH_END_COLOR][2] - ColorCurrent[ownerName][2])/diff;
            else
                ColorCurrent[ownerName][2] = ColorCurrent[ownerName][2] - CH[CH_SPEED]*(ColorCurrent[ownerName][2] - CH[CH_END_COLOR][2])/diff;
            try{CH[CH_OWNER].style.color = "rgb(" + parseInt(ColorCurrent[ownerName][0]) + ", " + parseInt(ColorCurrent[ownerName][1]) + ", " + parseInt(ColorCurrent[ownerName][2]) + ")";}
			catch(e){}
            return true;
        }
    };
    var SetBackgroundColorPlay = function(ownerName,index)
    {        
        var BCH = BackgroundColorHolder[ownerName][index-1];
        if(BCH[BCH_OWNER].style.backgroundColor.indexOf("inherit") != -1)
        {
            BCH[BCH_OWNER].style.backgroundColor = BCH[BCH_OWNER].parentNode.style.backgroundColor;
        }
        if(!BackgroundColorCurrent[ownerName] || BackgroundColorCurrent[ownerName] == "undefined")
        {
            BackgroundColorCurrent[ownerName] = colorToArray(BCH[BCH_OWNER].style.backgroundColor);
        }
        if(!BackgroundColorDefault[ownerName] || BackgroundColorDefault[ownerName] == "undefined")
        {
            if (BCH[BCH_END_COLOR].indexOf("%") != -1)
                BackgroundColorDefault[ownerName] =  colorToArray(BCH[BCH_OWNER].style.backgroundColor);
            else
               BackgroundColorDefault[ownerName] =  colorToArray(BCH[BCH_END_COLOR]); 
        }
        if (BCH[BCH_END_COLOR].indexOf("%") != -1)
        {
            var ratio = BCH[BCH_END_COLOR];
            BCH[BCH_END_COLOR] = [];
             
            ratio = parseFloat(ratio.replace("%",""))/100.0;
                
            if (BackgroundColorDefault[ownerName][0] > BackgroundColorDefault[ownerName][1] && BackgroundColorDefault[ownerName][0] > BackgroundColorDefault[ownerName][2])
            {
                if (Math.floor(BackgroundColorDefault[ownerName][0] * ratio) > 255)
                   ratio = 255/BackgroundColorDefault[ownerName][0];
            }
            else if (BackgroundColorDefault[ownerName][1] > BackgroundColorDefault[ownerName][0] && BackgroundColorDefault[ownerName][1] > BackgroundColorDefault[ownerName][2])
            {
                if (Math.floor(BackgroundColorDefault[ownerName][1] * ratio) > 255)
                   ratio = 255/BackgroundColorDefault[ownerName][1];
            }
            else
            {
                if (Math.floor(BackgroundColorDefault[ownerName][2] * ratio) > 255)
                   ratio = 255/BackgroundColorDefault[ownerName][2];
            }
            
            BCH[BCH_END_COLOR][0] = Math.floor(BackgroundColorDefault[ownerName][0] * ratio);
            BCH[BCH_END_COLOR][1] = Math.floor(BackgroundColorDefault[ownerName][1] * ratio);
            BCH[BCH_END_COLOR][2] = Math.floor(BackgroundColorDefault[ownerName][2] * ratio);
        }
        else
        {
            BCH[BCH_END_COLOR] = colorToArray(BCH[BCH_END_COLOR]);
        }
    }
    var BackgroundColorPlay = function(ownerName)
    { 
        var BCH = BackgroundColorHolder[ownerName][0];

        if (BCH[BCH_SPEED] < 0) 
            BCH[BCH_SPEED] = Math.abs(BCH[BCH_SPEED]);
            
        /*if (!BackgroundColorCurrent[ownerName])
            BackgroundColorCurrent[ownerName] = colorToArray(BCH[BCH_OWNER].style.color);*/
        
        var diff = Math.abs(BCH[BCH_END_COLOR][0] - BackgroundColorCurrent[ownerName][0]);
        if (diff < Math.abs(BCH[BCH_END_COLOR][1] - BackgroundColorCurrent[ownerName][1]))
            diff = Math.abs(BCH[BCH_END_COLOR][1] - BackgroundColorCurrent[ownerName][1]);
        if (diff < Math.abs(BCH[BCH_END_COLOR][2] - BackgroundColorCurrent[ownerName][2]))
            diff = Math.abs(BCH[BCH_END_COLOR][2] - BackgroundColorCurrent[ownerName][2]);
            
        
        if (diff == 0 || diff < BCH[BCH_SPEED])
        {
            BackgroundColorCurrent[ownerName][0] = BCH[BCH_END_COLOR][0];
            BackgroundColorCurrent[ownerName][1] = BCH[BCH_END_COLOR][1];
            BackgroundColorCurrent[ownerName][2] = BCH[BCH_END_COLOR][2];
            BCH[BCH_OWNER].style.backgroundColor = "rgb(" + parseInt(BackgroundColorCurrent[ownerName][0]) + ", " + parseInt(BackgroundColorCurrent[ownerName][1]) + ", " + parseInt(BackgroundColorCurrent[ownerName][2]) + ")";
            return false;
        }
        else
        {
            if (BackgroundColorCurrent[ownerName][0] < BCH[BCH_END_COLOR][0])
                BackgroundColorCurrent[ownerName][0] = BackgroundColorCurrent[ownerName][0] + BCH[BCH_SPEED]*(BCH[BCH_END_COLOR][0] - BackgroundColorCurrent[ownerName][0])/diff;
            else
                BackgroundColorCurrent[ownerName][0] = BackgroundColorCurrent[ownerName][0] - BCH[BCH_SPEED]*(BackgroundColorCurrent[ownerName][0] - BCH[BCH_END_COLOR][0])/diff;

            if (BackgroundColorCurrent[ownerName][1] < BCH[BCH_END_COLOR][1])
                BackgroundColorCurrent[ownerName][1] = BackgroundColorCurrent[ownerName][1] + BCH[BCH_SPEED]*(BCH[BCH_END_COLOR][1] - BackgroundColorCurrent[ownerName][1])/diff;
            else
                BackgroundColorCurrent[ownerName][1] = BackgroundColorCurrent[ownerName][1] - BCH[BCH_SPEED]*(BackgroundColorCurrent[ownerName][1] - BCH[BCH_END_COLOR][1])/diff;
                
            if (BackgroundColorCurrent[ownerName][2] < BCH[BCH_END_COLOR][2])
                BackgroundColorCurrent[ownerName][2] = BackgroundColorCurrent[ownerName][2] + BCH[BCH_SPEED]*(BCH[BCH_END_COLOR][2] - BackgroundColorCurrent[ownerName][2])/diff;
            else
                BackgroundColorCurrent[ownerName][2] = BackgroundColorCurrent[ownerName][2] - BCH[BCH_SPEED]*(BackgroundColorCurrent[ownerName][2] - BCH[BCH_END_COLOR][2])/diff;
            try{BCH[BCH_OWNER].style.backgroundColor = "rgb(" + parseInt(BackgroundColorCurrent[ownerName][0]) + ", " + parseInt(BackgroundColorCurrent[ownerName][1]) + ", " + parseInt(BackgroundColorCurrent[ownerName][2]) + ")";}
            catch(e){}
			return true;
        }
    };
    MM.pause = function(type,ownerName)
    {
        switch(type)
        {
            case MM_DESTINATION:if(DestinationHolder[ownerName])
	            DestinationHolder[ownerName][0][DH_PAUSE] = true;break;
            case MM_SIZE:if(SizeHolder[ownerName])
                SizeHolder[ownerName][0][SH_PAUSE] = true;break;
            case MM_FONT_SIZE:if(FontSizeHolder[ownerName])
                FontSizeHolder[ownerName][0][SFH_PAUSE] = true;break;
            case MM_ALPHA:if(AlphaHolder[ownerName])
            	AlphaHolder[ownerName][0][AH_PAUSE] = true;break;
            case MM_FOLLOW:if(FollowHolder[ownerName])
            	FollowHolder[ownerName][0][FH_PAUSE] = true;break;
            case MM_COLOR:if(ColorHolder[ownerName])
            	ColorHolder[ownerName][0][CH_PAUSE] = true;break;
            case MM_BACKGROUNDCOLOR:if(BackgroundColorHolder[ownerName])
            	BackgroundColorHolder[ownerName][0][BCH_PAUSE] = true;break;
        }
    };
    MM.unpause = function(type,ownerName)
    {
        switch(type)
        {
            case MM_DESTINATION:if(DestinationHolder[ownerName])
	            DestinationHolder[ownerName][0][DH_PAUSE] = false;break;
            case MM_SIZE:if(SizeHolder[ownerName])
                SizeHolder[ownerName][0][SH_PAUSE] = false;break;
            case MM_FONT_SIZE:if(FontSizeHolder[ownerName])
                FontSizeHolder[ownerName][0][SFH_PAUSE] = false;break;
            case MM_ALPHA:if(AlphaHolder[ownerName])
            	AlphaHolder[ownerName][0][AH_PAUSE] = false;break;
            case MM_FOLLOW:if(FollowHolder[ownerName])
            	FollowHolder[ownerName][0][FH_PAUSE] = false;break;
            case MM_COLOR:if(ColorHolder[ownerName])
            	ColorHolder[ownerName][0][CH_PAUSE] = false;break;
            case MM_BACKGROUNDCOLOR:if(BackgroundColorHolder[ownerName])
            	BackgroundColorHolder[ownerName][0][BCH_PAUSE] = false;break;
        }
    };
    MM.setWaitTime = function(type,ownerName,waitTime)
    {
        switch(type)
        {
            case MM_DESTINATION:if(DestinationHolder[ownerName])
	            DestinationHolder[ownerName][0][DH_WAIT_TIME] = waitTime;break;
            case MM_SIZE:if(SizeHolder[ownerName])
                SizeHolder[ownerName][0][SH_WAIT_TIME] = waitTime;break;
            case MM_FONT_SIZE:if(FontSizeHolder[ownerName])
                FontSizeHolder[ownerName][0][SFH_WAIT_TIME] = waitTime;break;
            case MM_ALPHA:if(AlphaHolder[ownerName])
            	AlphaHolder[ownerName][0][AH_WAIT_TIME] = waitTime;break;
            case MM_FOLLOW:if(FollowHolder[ownerName])
            	FollowHolder[ownerName][0][FH_WAIT_TIME] = waitTime;break;
            case MM_COLOR:if(ColorHolder[ownerName])
            	ColorHolder[ownerName][0][CH_WAIT_TIME] = waitTime;break;
            case MM_BACKGROUNDCOLOR:if(BackgroundColorHolder[ownerName])
            	BackgroundColorHolder[ownerName][0][BCH_WAIT_TIME] = waitTime;break;
        }
    };
    MM.clearWaitTime = function(type,ownerName)
    {
        switch(type)
        {
            case MM_DESTINATION:if(DestinationHolder[ownerName])
            	DestinationHolder[ownerName][0][DH_WAIT_TIME] = 0;break;
            case MM_SIZE:if(SizeHolder[ownerName])
            	SizeHolder[ownerName][0][SH_WAIT_TIME] = 0;break;
            case MM_FONT_SIZE:if(FontSizeHolder[ownerName])
            	FontSizeHolder[ownerName][0][SFH_WAIT_TIME] = 0;break;
            case MM_ALPHA:if(AlphaHolder[ownerName])
            	AlphaHolder[ownerName][0][AH_WAIT_TIME] = 0;break;
            case MM_FOLLOW:if(FollowHolder[ownerName])
            	FollowHolder[ownerName][0][FH_WAIT_TIME] = 0;break;
            case MM_COLOR:if(ColorHolder[ownerName])
            	ColorHolder[ownerName][0][CH_WAIT_TIME] = 0;break;
            case MM_BACKGROUNDCOLOR:if(BackgroundColorHolder[ownerName])
            	BackgroundColorHolder[ownerName][0][BCH_WAIT_TIME] = 0;break;
        }
    };
    MM.clear = function(type,ownerName)
    {
       switch(type)
       {
           case MM_DESTINATION:if(typeof DestinationHolder[ownerName] != 'undefined')
               delete DestinationHolder[ownerName];break;
           case MM_SIZE:if(typeof SizeHolder[ownerName] != 'undefined')
               delete SizeHolder[ownerName];break;
           case MM_FONT_SIZE:if(typeof FontSizeHolder[ownerName] != 'undefined')
               delete FontSizeHolder[ownerName];break;
           case MM_ALPHA:if(typeof AlphaHolder[ownerName] != 'undefined')
               delete AlphaHolder[ownerName];break;
           case MM_FOLLOW:if(typeof FollowHolder[ownerName] != 'undefined')
               delete FollowHolder[ownerName];break;
           case MM_COLOR:if(typeof ColorHolder[ownerName] != 'undefined')
               delete ColorHolder[ownerName];break;
           case MM_BACKGROUNDCOLOR:if(typeof BackgroundColorHolder[ownerName] != 'undefined')
               delete BackgroundColorHolder[ownerName];break;
       }
    };
    MM.unshift = function(type,ownerName,parameters)
    {
       switch(type)
       {
           case MM_DESTINATION:
               if(typeof DestinationHolder[ownerName] == 'undefined')
                   DestinationHolder[ownerName] = new Array();
               DestinationHolder[ownerName].unshift(parameters);break;
           case MM_SIZE:
               if(typeof SizeHolder[ownerName] == 'undefined')
                   SizeHolder[ownerName] = new Array();
               SizeHolder[ownerName].unshift(parameters);break;
           case MM_FONT_SIZE:
               if(typeof FontSizeHolder[ownerName] == 'undefined')
                   FontSizeHolder[ownerName] = new Array();
               FontSizeHolder[ownerName].unshift(parameters);break;
           case MM_ALPHA:
               if(typeof AlphaHolder[ownerName] == 'undefined')
                   AlphaHolder[ownerName] = new Array();
               AlphaHolder[ownerName].unshift(parameters);break;
           case MM_FOLLOW:
               if(typeof FollowHolder[ownerName] == 'undefined')
                   FollowHolder[ownerName] = new Array();
               FollowHolder[ownerName].unshift(parameters);break;
           case MM_COLOR:
               if(typeof ColorHolder[ownerName] == 'undefined')
                   ColorHolder[ownerName] = new Array();
               ColorHolder[ownerName].unshift(parameters);
               SetColorPlay(ownerName,1);break;
           case MM_BACKGROUNDCOLOR:
               if(typeof BackgroundColorHolder[ownerName] == 'undefined')
                   BackgroundColorHolder[ownerName] = new Array();
               BackgroundColorHolder[ownerName].unshift(parameters);
               SetBackgroundColorPlay(ownerName,1);break;
       }
    };
    MM.push = function(type,ownerName,parameters)
    {
       switch(type)
       {
           case MM_DESTINATION:
               if(typeof DestinationHolder[ownerName] == 'undefined')
                   DestinationHolder[ownerName] = new Array();
               DestinationHolder[ownerName].push(parameters);break;
           case MM_SIZE:
               if(typeof SizeHolder[ownerName] == 'undefined')
                   SizeHolder[ownerName] = new Array();
               SizeHolder[ownerName].push(parameters);break;
           case MM_FONT_SIZE:
               if(typeof FontSizeHolder[ownerName] == 'undefined')
                   FontSizeHolder[ownerName] = new Array();
               FontSizeHolder[ownerName].push(parameters);break;
           case MM_ALPHA:
               if(typeof AlphaHolder[ownerName] == 'undefined')
                   AlphaHolder[ownerName] = new Array();
               AlphaHolder[ownerName].push(parameters);break;
           case MM_FOLLOW:
               if(typeof FollowHolder[ownerName] == 'undefined')
                   FollowHolder[ownerName] = new Array();
               FollowHolder[ownerName].push(parameters);break;
           case MM_COLOR:
               if(typeof ColorHolder[ownerName] == 'undefined')
                   ColorHolder[ownerName] = new Array();
               SetColorPlay(ownerName,ColorHolder[ownerName].push(parameters));break;
           case MM_BACKGROUNDCOLOR:
               if(typeof BackgroundColorHolder[ownerName] == 'undefined')
                   BackgroundColorHolder[ownerName] = new Array();
               SetBackgroundColorPlay(ownerName,BackgroundColorHolder[ownerName].push(parameters));break;
       }
    };
    MM.CenterAbsolute = function(horizontal,vertical, owner,_parentNode)
    {
        var _parentNode = (typeof _parentNode == 'undefined') ? owner.parentNode : _parentNode;
        if(!_parentNode)
            return;

        var horizontal = (typeof horizontal == "undefined" ? true : horizontal);
        var vertical = (typeof vertical == "undefined" ? true : vertical);
        var parentIndex = (typeof parentIndex == "undefined" ? 0 : parentIndex);
        
        var ParentNode;
        for(ParentNode = _parentNode; parentIndex; ParentNode = ParentNode.parentNode,parentIndex--);

        if(horizontal)
            owner.style.left = ((ParentNode.offsetWidth - owner.offsetWidth)/8 ).toFixed(2) + "px";
            
        if(vertical)
            owner.style.top = ((ParentNode.offsetHeight - owner.offsetHeight)/8).toFixed(2) + "px";
    };
    MM.AbsoluteOffset = function(owner)
    {
        var _OffSetLeft = owner.offsetLeft;
        var _OffSetTop = owner.offsetTop;
        
        //Seem to have 1 Pixel Bigger... on FF 
        var _EleParent = owner.offsetParent;
        if(_EleParent)
        {
            do
            {
                _OffSetLeft += _EleParent.offsetLeft;
                _OffSetTop += _EleParent.offsetTop;
            }while(_EleParent = _EleParent.offsetParent) 
        }
        return [_OffSetTop,_OffSetLeft];
    };
    MM.update = function()
    {
        var _Timer = new Date().getTime();
        Diff = (_Timer - Timer);
        Timer = _Timer;
        //try{
        for(var ownerName in DestinationHolder)
        {
            if (DestinationHolder[ownerName][0][DH_WAIT_TIME] < Diff) 
                DestinationHolder[ownerName][0][DH_WAIT_TIME] = 0;
            else 
            {
                DestinationHolder[ownerName][0][DH_WAIT_TIME] -= Diff;
                continue;
            }
            if(DestinationHolder[ownerName][0][DH_PAUSE])
                continue;

            if (!Move(ownerName))
            { 
                if(DestinationHolder[ownerName][0][DH_FINAL] != null)
                    DestinationHolder[ownerName][0][DH_FINAL](DestinationHolder[ownerName][0][DH_OWNER]);  
                DestinationHolder[ownerName].shift();
            }
            if(!DestinationHolder[ownerName].length)
	            delete DestinationHolder[ownerName];    
        }
        for(var ownerName in SizeHolder)
        {
            if (SizeHolder[ownerName][0][SH_WAIT_TIME] < Diff) 
                SizeHolder[ownerName][0][SH_WAIT_TIME] = 0;
            else 
            {
                SizeHolder[ownerName][0][SH_WAIT_TIME] -= Diff;
                continue;
            }
            if(SizeHolder[ownerName][0][SH_PAUSE])
                continue;

            if (!Resize(ownerName))
            { 
                if(SizeHolder[ownerName][0][SH_FINAL] != null)
                    SizeHolder[ownerName][0][SH_FINAL](SizeHolder[ownerName][0][SH_OWNER]);  
                SizeHolder[ownerName].shift();
            }
            if(!SizeHolder[ownerName].length)
	            delete SizeHolder[ownerName];    
        }
        for(var ownerName in FontSizeHolder)
        {
            if (FontSizeHolder[ownerName][0][SFH_WAIT_TIME] < Diff) 
                FontSizeHolder[ownerName][0][SFH_WAIT_TIME] = 0;
            else 
            {
                FontSizeHolder[ownerName][0][SFH_WAIT_TIME] -= Diff;
                continue;
            }
            if(FontSizeHolder[ownerName][0][SFH_PAUSE])
                continue;

            if (!ResizeFont(ownerName))
            { 
                if(FontSizeHolder[ownerName][0][SFH_FINAL] != null)
                    FontSizeHolder[ownerName][0][SFH_FINAL](FontSizeHolder[ownerName][0][SFH_OWNER]);  
                FontSizeHolder[ownerName].shift();
            }
            if(!FontSizeHolder[ownerName].length)
	            delete FontSizeHolder[ownerName];    
        }
        for(var ownerName in AlphaHolder)
        {
            if (AlphaHolder[ownerName][0][AH_WAIT_TIME] < Diff) 
                AlphaHolder[ownerName][0][AH_WAIT_TIME] = 0;
            else 
            {
                AlphaHolder[ownerName][0][AH_WAIT_TIME] -= Diff;
                continue;
            }
            if(AlphaHolder[ownerName][0][AH_PAUSE])
                continue;
            if (!AlphaPlay(ownerName))
            { 
                if(AlphaHolder[ownerName][0][AH_FINAL] != null)
                    AlphaHolder[ownerName][0][AH_FINAL](AlphaHolder[ownerName][0][AH_OWNER]);    
                AlphaHolder[ownerName].shift();
            }
            if(!AlphaHolder[ownerName].length)
	            delete AlphaHolder[ownerName];    
        }
        for(var ownerName in FollowHolder)
        {
            if (FollowHolder[ownerName][0][FH_WAIT_TIME] < Diff) 
                FollowHolder[ownerName][0][FH_WAIT_TIME] = 0;
            else 
            {
                FollowHolder[ownerName][0][FH_WAIT_TIME] -= Diff;
                continue;
            }
            if(FollowHolder[ownerName][0][FH_PAUSE])
                continue;

            if (!Follow(ownerName))
            {
                if(FollowHolder[ownerName][0][FH_FINAL] != null)
                    FollowHolder[ownerName][0][FH_FINAL](FollowHolder[ownerName][0][FH_OWNER]); 
                FollowHolder[ownerName].shift();
         }
            if(!FollowHolder[ownerName].length)
	            delete FollowHolder[ownerName];    
        }
        for(var ownerName in ColorHolder)
        {
            if (ColorHolder[ownerName][0][CH_WAIT_TIME] < Diff) 
                ColorHolder[ownerName][0][CH_WAIT_TIME] = 0;
            else 
            {
                ColorHolder[ownerName][0][CH_WAIT_TIME] -= Diff;
                continue;
            }
            if(ColorHolder[ownerName][0][CH_PAUSE])
                continue;

            if (!ColorPlay(ownerName))
            {
                if(ColorHolder[ownerName][0][CH_FINAL] != null)
                    ColorHolder[ownerName][0][CH_FINAL](ColorHolder[ownerName][0][CH_OWNER]); 
                ColorHolder[ownerName].shift();
            }

            if(!ColorHolder[ownerName].length)
	            delete ColorHolder[ownerName];    
        }
        for(var ownerName in BackgroundColorHolder)
        {
            if (BackgroundColorHolder[ownerName][0][BCH_WAIT_TIME] < Diff) 
                BackgroundColorHolder[ownerName][0][BCH_WAIT_TIME] = 0;
            else 
            {
                BackgroundColorHolder[ownerName][0][BCH_WAIT_TIME] -= Diff;
                continue;
            }
            if(BackgroundColorHolder[ownerName][0][BCH_PAUSE])
                continue;

            if (!BackgroundColorPlay(ownerName))
            {
                if(BackgroundColorHolder[ownerName][0][BCH_FINAL] != null)
                    BackgroundColorHolder[ownerName][0][BCH_FINAL](BackgroundColorHolder[ownerName][0][BCH_OWNER]); 
                BackgroundColorHolder[ownerName].shift();
            }

            if(!BackgroundColorHolder[ownerName].length)
	            delete BackgroundColorHolder[ownerName];    
        }
        //}catch(e){alert(e);}
    };
})();

function moveInArc(ele, posDataType, arcAngle, arcResolution, moveSpeed, radius)
{
    if (arcResolution < 0.01 || moveSpeed < 0.01)
        return;
        
    var Left = parseFloat(ele.style.left);
    var Top = parseFloat(ele.style.top);
    if(arcAngle < 0)
        arcResolution = -arcResolution;

    while ((arcAngle > 0.0 && arcResolution > 0.0) || (arcAngle < 0.0 && arcResolution < 0.0))
    {
        Left += Math.cos(arcAngle)*radius;
        Top -= Math.sin(arcAngle)*radius;
        MM.push(MM_DESTINATION, ele.id, [Top, Left, null,null,moveSpeed,null, posDataType,null,ele, 0, false]);
        arcAngle -= arcResolution;
    }
}
function Debug(){}(function()
{
    var EleWrapper = null;

    Debug.add = function(text)
    {
        if(EleWrapper.style.display = "none")
            EleWrapper.style.display = "block";

        EleWrapper.appendChild(document.createElement("p")).innerHTML = text;
        EleWrapper.scrollTop = EleWrapper.scrollHeight;
    };
    Debug.init = function()
    {
        var ele = document.createElement('div');
        ele.id = "debugWrapper";
        ele.ondblclick = function(){this.style.display = 'none';};
        ele.style.display = 'none';
        ele.style.overflow = 'scroll';
        ele.style.position = 'absolute';
        ele.style.top = "0";
        ele.style.width = '200px';
        ele.style.height= '400px'
        
        EleWrapper = ele;
        document.body.appendChild(ele);
    };
})();

function Mouse() { this._construct() } (function()
{ 
	var ScrollTarget = null;
	
	Mouse.coord = new Array();
	Mouse.coord['x'] = 0;
	Mouse.coord['y'] = 0;
	Mouse.down = false;
    
    var Scroll = function(delta)
    {
    	if(ScrollTarget)
        {
            ScrollTarget.scrollTop = ScrollTarget.scrollTop + delta * 20;
            return;
        }
        delta *= 50;
    	if (delta > 0)
    		window.scrollBy(0,delta);
    	else
    		window.scrollBy(0,delta);
    };
    Mouse.wheel = function(event)
    {
    	var delta = 0;

    	if(!event) //Fix For Moron
    		event = window.event;

    	if (event.wheelDelta)  //Opera
    		delta = -(event.wheelDelta/120);
    	else if (event.detail) //Mozilla case.
    		delta = event.detail/3;

    	if(delta < 0)
    		Scroll(delta);
    	else if( delta > 0)
    		Scroll(delta);

    	//Disable Normal Scroll Function
    	//if(owner.preventDefault)
    		//owner.preventDefault();
    	//owner.returnValue = false;
    }
    Mouse.SetScrollTarget = function(owner)
    {
        if(owner != ScrollTarget)
            ScrollTarget = owner;
    };
})();
