﻿
/******************************************************************************************************************************/
/****************************************** LIBRARY DESCRIPTION START *********************************************************/
/******************************************************************************************************************************/

/** COMMON START            */
/** SEARCH CONTROL START    */
/** POPUP START             */
/** PAGE SELECTOR START     */
/** MAIN MENU START         */
/** MEDIA START             */
/** HOMEPAGE BANNER START   */
/** FORM START              */

/******************************************************************************************************************************/
/****************************************** LIBRARY DESCRIPTION END ***********************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** GOOGLE ANALYTICS START ************************************************************/
/******************************************************************************************************************************/

try 
{	
    var pageTracker = _gat._getTracker("UA-178399-2");
    pageTracker._trackPageview();
} 
catch(err) 
{
}

/******************************************************************************************************************************/
/****************************************** GOOGLE ANALYTICS END **************************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** STAT COUNTER START ****************************************************************/
/******************************************************************************************************************************/

sc_project=454836; 
sc_invisible=1; 
sc_partition=2; 

/******************************************************************************************************************************/
/****************************************** STAT COUNTER END ****************************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** COMMON START **********************************************************************/
/******************************************************************************************************************************/

function MST()
{
}

MST.Inited = false;

MST.CreateHtmlAttribute = function(name, value) 
{
   var attribute = document.createAttribute(name)
   attribute.nodeValue = value
   return attribute
}

MST.Common = function()
{
}

MST.Common.OnLoad = function()
{
    if (MST.Controls.Banner.Init != null)
    {
        MST.Controls.Banner.Init();
    }
    
    MST.Inited = true;
}

MST.Controls = function ()
{
}

MST.Common.FindParentById = function (ctrl, id)
{
    for (var parent = ctrl.parentNode;
         parent != null && parent.id != id;
         parent = parent.parentNode)
    { }

    return parent;
}

MST.Common.FindParentByTagType = function (ctrl, tagType)
{
    for (var parent = ctrl.parentNode;
         parent != null && parent.tagName != tagType;
         parent = parent.parentNode)
    { }

    return parent;
}

/**************** Find childs methods **********************/

MST.Common.FindDirectChildById = function (ctrl, id)
{
    for (var i = 0; i < ctrl.childNodes.length; i++)
    {
        if (ctrl.childNodes[i].id == id)
        {
            return ctrl.childNodes[i];
        }
    }
    
    return null;
}

MST.Common.FindChildsByCriteria = function (ctrl, compareFunc)
{
    var resultArray = new Array();
    {
        this.FindChildsByCriteriaInternal(ctrl, compareFunc, resultArray);
    }
    
    return resultArray;
}

MST.Common.FindChildsByCriteriaInternal = function (ctrl, compareFunc, resultArray)
{
    if (ctrl == null)
    {
        return;
    }

    for(var child in ctrl.childNodes)
    {
        var childNode = ctrl[child];

        if (childNode == null)
        {
            continue;
        }
    
        if (compareFunc(childNode))
        {
            resultArray.push(childNode);
        }

        if (childNode != null)
        {
            this.FindChildsByCriteriaInternal(childNode, compareFunc, resultArray);
        }
    }
}

/**************** Find childs methods ************************************************************************************/

MST.Common.GetText = function (ctrl)
{
    var content = null;

    if (content == null
        && ctrl.innerText != null)
    {
        content = ctrl.innerText;
    }

    if (content == null
        && ctrl.textContent != null)
    {
        content = ctrl.textContent
    }

    return content;
}

MST.Common.SetText = function (ctrl, text)
{
    if (ctrl.innerText != null)
    {
        ctrl.innerText = text;
    }

    if (ctrl.textContent != null)
    {
        ctrl.textContent = text;
    }
}

MST.Common.CancelEvent = function (event)
{
    if (event.cancelBubble != null)
    {
        event.cancelBubble = true;
    }
    else if (event.stopPropagation != null)
    {
	    event.stopPropagation();
    }
}

/******************************************************************************************************************************/
/****************************************** COMMON END ************************************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** FORM START ************************************************************************/
/******************************************************************************************************************************/

MST.Form = function()
{
}

MST.Form.DoPostBack = function(form)
{
    if (form.submit != null)
    {
        var formId = form.name + "_FormIdentifier";
        var existingForm = document.getElementById(formId);
        
        if (existingForm != null)
        {
            existingForm.parent.removeChild(existingForm);
        }

        var formField = document.createElement("input");
        {
            formField.setAttributeNode(MST.CreateHtmlAttribute("type", "hidden"))
            //formField.type  = "hidden";
            formField.name  = "FormName";
            formField.id = formId;
            formField.value = form.name;
        }
        
        form.appendChild(formField);
        form.submit();
    }
}

/******************************************************************************************************************************/
/****************************************** FORM END **************************************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** SEARCH CONTROL START **************************************************************/
/******************************************************************************************************************************/


MST.Controls.SearchControl = function SearchControl()
{
}

MST.Controls.SearchControl.MaxMatchCount = 10;
MST.Controls.SearchControl.CurrentKeyword = null;
MST.Controls.SearchControl.SelectedKeyword = null;
MST.Controls.SearchControl.KeywordsVisible = false;
MST.Controls.SearchControl.IsMouseOver = false;

MST.Controls.SearchControl.InputValue = "";

MST.Controls.SearchControl.ContainsString = function (source, pattern)
{
    if (pattern.length == 0)
    {
        return false;
    }

    var re = new RegExp("^" + pattern + ".*", "i");
   
    return source.match(re);
}

MST.Controls.SearchControl.GetContent = function (item)
{
    return MST.Common.GetText(item);
}

MST.Controls.SearchControl.GetMainWrapper = function (obj)
{
    return MST.Common.FindParentById(obj, "top_search");
}

MST.Controls.SearchControl.GetKeywordsWrapper = function (mainWrapper)
{
    return MST.Common.FindDirectChildById(mainWrapper, "quick_search");
}

MST.Controls.SearchControl.GetKeywordItemsWrapper = function (mainWrapper)
{
    var kwrapper = MST.Common.FindDirectChildById(mainWrapper, "quick_search");
    
    return MST.Common.FindDirectChildById(kwrapper, "quick_search_items");
}

MST.Controls.SearchControl.GetKeywordsListWrapper = function (mainWrapper)
{
    return MST.Common.FindDirectChildById(
        this.GetKeywordsWrapper(mainWrapper)
        , "quick_search_items");
}

MST.Controls.SearchControl.GetInput = function (obj)
{
    var mainWrapper = this.GetMainWrapper(obj);
    var inputWrapper = MST.Common.FindDirectChildById(mainWrapper, "search_field");
    
    return MST.Common.FindDirectChildById(inputWrapper, "SearchControl_Query");
}

MST.Controls.SearchControl.GetGoButton = function (obj)
{
    var mainWrapper = this.GetMainWrapper(obj);
    
    return MST.Common.FindDirectChildById(mainWrapper, "go_button");
}

MST.Controls.SearchControl.Submit = function (obj)
{
    MST.Form.DoPostBack(
        this.GetMainWrapper(obj));
}

MST.Controls.SearchControl.SetGoButtonState = function (obj)
{
    var buttonWrapper = this.GetGoButton(obj);
    var input = this.GetTextInput(obj);
    var button = MST.Common.FindDirectChildById(buttonWrapper, "submit_button");
    
    var enabled = input.value != "";

    button.disabled = !enabled;
            
    if (enabled)
    {
        buttonWrapper.className = "my_small_button b_normal";
        buttonWrapper.onmouseover = this.GoButtonOver;
        buttonWrapper.onmouseout = this.GoButtonOut;
        buttonWrapper.onmousedown = this.GoButtonDown;
        buttonWrapper.onmouseup = this.GoButtonUp;
    }
    else
    {
        buttonWrapper.className = "my_small_button b_disabled";

        buttonWrapper.onmouseover = null;
        buttonWrapper.onmouseout = null;
        buttonWrapper.onmousedown = null;
        buttonWrapper.onmouseup = null;
    }
    
    return enabled;
}

MST.Controls.SearchControl.GoButtonOver = function (aEvent)
{
    var myEvent = aEvent ? aEvent : window.event;
    var btn = myEvent.srcElement ? MST.Common.FindParentById(myEvent.srcElement, "go_button") : myEvent.currentTarget;

    btn.className = 'my_small_button b_over';
}

MST.Controls.SearchControl.GoButtonOut = function (aEvent)
{
    var myEvent = aEvent ? aEvent : window.event;
    var btn = myEvent.srcElement ? MST.Common.FindParentById(myEvent.srcElement, "go_button") : myEvent.currentTarget;

    btn.className = 'my_small_button b_normal';
}

MST.Controls.SearchControl.GoButtonDown = function (aEvent)
{
    var myEvent = aEvent ? aEvent : window.event;
    var btn = myEvent.srcElement ? MST.Common.FindParentById(myEvent.srcElement, "go_button") : myEvent.currentTarget;

    btn.className = 'my_small_button b_down';
}

MST.Controls.SearchControl.GoButtonUp = function (aEvent)
{
    var myEvent = aEvent ? aEvent : window.event;
    var btn = myEvent.srcElement ? MST.Common.FindParentById(myEvent.srcElement, "go_button") : myEvent.currentTarget;

    btn.className = 'my_small_button b_normal';
}

MST.Controls.SearchControl.GetTextInput = function (obj)
{
    var inputWrapper = MST.Common.FindDirectChildById(this.GetMainWrapper(obj), "search_field");
    
    return MST.Common.FindDirectChildById(inputWrapper, "SearchControl_Query");
}

MST.Controls.SearchControl.HideKeywords = function (obj)
{
    var wrapper = MST.Common.FindParentById(obj, "top_search");
    var keywordsWrapper = MST.Common.FindDirectChildById(wrapper, "quick_search");

    this.Keyword_Unselect();
    keywordsWrapper.style.display = "none";
    this.KeywordsVisible = false;
}

MST.Controls.SearchControl.ShowKeywords = function (obj)
{
    var wrapper = MST.Common.FindParentById(obj, "top_search");
    var keywordsWrapper = MST.Common.FindDirectChildById(wrapper, "quick_search");

    keywordsWrapper.style.display = "block";
    this.KeywordsVisible = true;
}

MST.Controls.SearchControl.ProceedKeywords = function (input)
{
    var wrapper = this.GetMainWrapper(input);
    var matchCount = 0;

    if (wrapper != null)
    {
        var keywordsWrapper = this.GetKeywordsListWrapper(wrapper);

        for (var i = 0; i < keywordsWrapper.childNodes.length && matchCount < this.MaxMatchCount; i++)
        {
            var item = keywordsWrapper.childNodes[i];

            if (this.ContainsString(this.GetContent(item), input.value))
            {
                item.style.display = "block";
                matchCount++;
            }
            else
            {
                item.style.display = "none";
            }
        }

        if (matchCount == 0)
        {
            this.HideKeywords(input);
        }
        else
        {
            this.ShowKeywords(input);
        }
    }
    
    return matchCount;
}

MST.Controls.SearchControl.Keyword_MoveUp = function (input)
{
    var list = this.GetKeywordItemsWrapper(this.GetMainWrapper(input));
    var newSelection = null;
    
    if (this.SelectedKeyword != null)
    {
        var tmp = this.SelectedKeyword.parentNode;

        do
        {
            tmp = tmp.previousSibling;
        }
        while(tmp != null
              && tmp.style.display == "none");

        newSelection = tmp;
    }

    if (newSelection != null)
    {
        this.Keyword_Select(newSelection.childNodes[0]);
    }
    else
    {
        this.Keyword_Unselect();
    }
}

MST.Controls.SearchControl.Keyword_MoveDown = function (input)
{
    var list = this.GetKeywordItemsWrapper(this.GetMainWrapper(input));
    var newSelection = null;
    
    if (this.SelectedKeyword != null)
    {
        var tmp = this.SelectedKeyword.parentNode;

        do
        {
            tmp = tmp.nextSibling;
        }
        while(tmp != null
              && tmp.style.display == "none");

        newSelection = tmp;
    }
    else
    {
        for(var item in list.childNodes)
        {
            if (list.childNodes[item] == null
                || list.childNodes[item].style == null)
            {
                continue;
            }
        
            if (list.childNodes[item].style.display != "none")
            {
                newSelection = list.childNodes[item];
                break;
            }
        }
    }

    if (newSelection != null)
    {
        this.Keyword_Select(newSelection.childNodes[0]);
    }
}

MST.Controls.SearchControl.Keyword_ApplyCurrentToInput = function ()
{
    if (this.SelectedKeyword != null)
    {
        this.GetInput(this.SelectedKeyword).value = MST.Common.GetText(this.SelectedKeyword);
        this.HideKeywords(this.SelectedKeyword);
    }
}

MST.Controls.SearchControl.Keyword_Select = function (keywordWrapper)
{
    if (keywordWrapper != null)
    {
        this.ShowKeywords(keywordWrapper);
        this.Keyword_Unselect();
        
        keywordWrapper.className = "quick_search_keyword_hover";
        this.SelectedKeyword = keywordWrapper;
        this.CurrentKeyword = MST.Common.GetText(keywordWrapper);
    }
}

MST.Controls.SearchControl.Keyword_Unselect = function ()
{
    if (this.SelectedKeyword != null)
    {
        this.SelectedKeyword.className = "quick_search_keyword_normal";
        this.SelectedKeyword = null;
        this.CurrentKeyword = null;
    }
}

MST.Controls.SearchControl.HandleCommandKeys = function (input, event)
{
    switch (event.keyCode)
    {
        case 38:    // up
            this.Keyword_MoveUp(input);
            return true;
        case 40:    // down
            this.Keyword_MoveDown(input);
            return true;
        case 27:    // esc
            this.HideKeywords(input);
            input.value = this.InputValue;
            return true;
        case 13:    // enter
            this.Keyword_ApplyCurrentToInput();
            this.Submit(input);
            return true;
    }

    return false;
}

MST.Controls.SearchControl.ControlValid = function (obj)
{
    var success = true;

//        if (success
//            && this.KeywordsVisible)
//        {
//            success = false;    
//        }
//        
    return success;
}

MST.Controls.SearchControl.OnKeyUp = function (obj)
{
    var input;
    var event = obj;

    if (obj != null)
    {
        input = obj.currentTarget;
    }

    if (event == null)
    {
        event = window.event;
    }

    if (input == null
        && window.event != null)
    {
        input = window.event.srcElement;
    }

    if (input == null
        || input.id != "SearchControl_Query")
    {
        return;    
    }

    if (!this.HandleCommandKeys(input, event))
    {
        this.ProceedKeywords(input);
        this.InputValue = input.value;
    }

    this.SetGoButtonState(input);

    MST.Common.CancelEvent(event);
    event.returnValue = false;
    return false;
}

MST.Controls.SearchControl.OnFocus = function (input)
{
    var wrapper = MST.Common.FindParentById(input, "top_search");
    var keywordsWrapper = MST.Common.FindDirectChildById(wrapper, "quick_search");

    if (this.ProceedKeywords(input) > 0)
    {
        keywordsWrapper.style.display = "block";
    }
    else
    {
        keywordsWrapper.style.display = "none";
    }

    input.className = "search_field_input_focus";
}

MST.Controls.SearchControl.OnBlur = function (input, event)
{
    if (this.CurrentKeyword != null)
    {
        input.value = this.CurrentKeyword;
    }

    var button = this.GetGoButton(input);

    if (input.value == "")
    {
        input.className = "search_field_input";
    }
    else
    {
        input.className = "search_field_input_focus";
    }

    var enabled = this.SetGoButtonState(input);
    this.HideKeywords(input);
    
    if (enabled
        && this.IsMouseOver)
    {
        this.Submit(input)
    }
}

MST.Controls.SearchControl.OnMouseOver_Keyword = function (sender)
{   
    this.Keyword_Select(sender);
    this.IsMouseOver = true;

    if (sender.textContent != null)
    {
        this.CurrentKeyword = sender.textContent;
    }
    else if (sender.innerText)
    {
        this.CurrentKeyword = sender.innerText;
    }
}

MST.Controls.SearchControl.OnMouseOut_Keyword = function ()
{
    this.IsMouseOver = false;
    //this.Keyword_Unselect();

    this.CurrentKeyword = null;
}

MST.Controls.SearchControl.OnSubmit = function (form, event)
{
    MST.Common.CancelEvent(event);

    //return this.ControlValid(form);
    return false;
}

MST.Controls.SearchControl.OnKeywordWrapper_Click = function (sender)
{
    this.Submit(sender);
}

MST.Controls.SearchControl.GoButtonClicked = function (sender)
{
    var success = this.ControlValid(sender);

    if (success)
    {
        this.Submit(sender);
    }

    return success;
}

/******************************************************************************************************************************/
/****************************************** SEARCH CONTROL END ****************************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** POPUP START ***********************************************************************/
/******************************************************************************************************************************/

MST.Controls.Popup = function()
{
}

MST.Controls.Popup.FindPopup = function()
{
    return document.getElementById('root_PopupDialog');
}

MST.Controls.Popup.FindWrapper = function()
{
    return document.getElementById('root_PopupDialog_wrapper');
}


MST.Controls.Popup.FindContent = function()
{
    return document.getElementById('root_PopupDialog_content');
}

MST.Controls.Popup.FindTitle = function()
{
    return document.getElementById('root_PopupDialog_title');
}

MST.Controls.Popup.Open = function(content, title, width)
{
    if (title != null)
    {
        this.SetTitle(title);
    }

    this.SetContent(content);
    this.SetDisplay("block");

    if (width != null)
    {
        this.FindWrapper().style.width = width;
    }
}

MST.Controls.Popup.Close = function()
{
    this.SetDisplay("none");
    this.CleanContent();
}

MST.Controls.Popup.SetContent = function(content)
{
    this.FindContent().innerHTML = content;
}

MST.Controls.Popup.SetTitle = function(title)
{
    this.FindTitle().innerHTML = title;
}

MST.Controls.Popup.CleanContent = function()
{
    this.SetContent("");
}

/******************************************************************************************************************************/
/****************************************** POPUP END *************************************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** PAGE SELECTOR START ***************************************************************/
/******************************************************************************************************************************/

MST.Controls.PageSelector = function()
{
}

MST.Controls.PageSelector.Form = function(obj)
{
    return document.getElementById("PageSelectorForm");
}

MST.Controls.PageSelector.CommandInput = function(obj)
{
    var form = MST.Controls.PageSelector.Form(obj);
    return MST.Common.FindDirectChildById(form, "PageSelectorForm_CommandInput");
}

MST.Controls.PageSelector.SubmitForm = function(obj)
{
    MST.Form.DoPostBack(this.Form(obj));
}

MST.Controls.PageSelector.GetPageNumber = function(sender)
{
    var text = MST.Common.GetText(sender);
    return parseInt(text) - 1;
}

MST.Controls.PageSelector.MoveToPage = function(sender)
{
    var page = this.GetPageNumber(sender)
    
    this.CommandInput(sender).value = page.toString();
    this.SubmitForm();
}

MST.Controls.PageSelector.Move = function(sender, command)
{
    this.CommandInput(sender).value = command;
    this.SubmitForm();
}

/******************************************************************************************************************************/
/****************************************** PAGE SELECTOR END *****************************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** MAIN MENU START *******************************************************************/
/******************************************************************************************************************************/

MST.Controls.MainMenu = function MainMenu()
{
}

MST.Controls.MainMenu.ShowTimeout = 300;
MST.Controls.MainMenu.HideTimeout = 1000;

MST.Controls.MainMenu.LinkActive = false;
MST.Controls.MainMenu.TimerId = -1;
MST.Controls.MainMenu.CurrentDropDown = null;
MST.Controls.MainMenu.DropDownVisible = false;
MST.Controls.MainMenu.AllowDropDown = true;
MST.Controls.MainMenu.ShowInProcess = false;

MST.Controls.MainMenu.Wrapper = function (obj)
{
    return MST.Common.FindParentById(
        obj
        , "main_menu");
}

MST.Controls.MainMenu.SetTimer = function (timeout, alertFunction)
{
    this.CancelTimer();
    
    this.TimerId = setTimeout(
        alertFunction
        , timeout)
}

MST.Controls.MainMenu.CancelTimer = function ()
{
    this.ShowInProcess = false;

    clearTimeout(this.TimerId);
}

MST.Controls.MainMenu.SetFocused = function ()
{
    var dropDown = MST.Controls.MainMenu.CurrentDropDown;

    if (dropDown != null)
    {
        MST.Common.FindDirectChildById(dropDown, "clickListener").focus();
    }
}

MST.Controls.MainMenu.ShowDropDownStart = function (dropDown)
{
    if (dropDown != this.CurrentDropDown)
    {
        this.HideDropDown();

        if (dropDown != null)
        {
            this.CurrentDropDown = dropDown;
            this.ShowInProcess = true;
            this.SetTimer(
                MST.Controls.MainMenu.ShowTimeout
                , this.ShowDropDownAlert);
        }
    }
}

MST.Controls.MainMenu.ShowDropDownAlert = function()
{
    this.ShowInProcess = false;

    if (!MST.Controls.MainMenu.AllowDropDown)
    {
        MST.Controls.MainMenu.HideDropDown();
        return;
    }

    var dropDown = MST.Controls.MainMenu.CurrentDropDown;

    if (dropDown != null)
    {
        dropDown.style.display = "block";
        MST.Controls.MainMenu.SetFocused();
        MST.Controls.MainMenu.DropDownVisible = true;
    }
}

MST.Controls.MainMenu.HideDropDownStart = function ()
{
    this.SetTimer(
        this.HideTimeout
        , this.HideDropDownAlert);
}

MST.Controls.MainMenu.HideDropDownAlert = function ()
{
    if (MST.Controls.MainMenu.AllowDropDown)
    {
        return;
    }

    MST.Controls.MainMenu.HideDropDown();
}

MST.Controls.MainMenu.HideDropDown = function ()
{
    var dropDown = MST.Controls.MainMenu.CurrentDropDown;


    if (dropDown != null)
    {
        dropDown.style.display = "none";
        MST.Controls.MainMenu.DropDownVisible = false;
        MST.Controls.MainMenu.CurrentDropDown = null;
    }
}

MST.Controls.MainMenu.OnMouseOver_TopItem = function (obj)
{
    this.AllowDropDown = true;

    if (!this.ShowInProcess)
    {
        var dropDown = MST.Common.FindDirectChildById(
            obj
            , "mm_popup");

        this.ShowDropDownStart(dropDown);
    }
}

MST.Controls.MainMenu.OnMouseOut_TopItem = function ()
{
    this.AllowDropDown = false;
}

MST.Controls.MainMenu.OnMouseOver_TopActiveItem = function ()
{
    this.AllowDropDown = true;
}

MST.Controls.MainMenu.OnMouseOut_TopActiveItem = function ()
{
    this.AllowDropDown = false;
}

MST.Controls.MainMenu.OnMouseOut = function ()
{
    this.HideDropDownStart();
}

MST.Controls.MainMenu.OnBlur = function (sender)
{
    if (!this.LinkActive)
    {
        this.HideDropDownAlert();
    }
}

MST.Controls.MainMenu.OnClick_TopItem = function ()
{
    MST.Controls.MainMenu.SetFocused();
}

MST.Controls.MainMenu.OnMouseOut_Link = function ()
{
    this.LinkActive = false;
}

MST.Controls.MainMenu.OnMouseOver_Link = function ()
{
    this.LinkActive = true;
}

/******************************************************************************************************************************/
/****************************************** MAIN MENU END *********************************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** MEDIA START ***********************************************************************/
/******************************************************************************************************************************/

MST.Media = function()
{
}

MST.Media.IFrame = function()
{
}

MST.Media.IFrame.Create = function(src, width, height)
{
    var obj = 
      "<iframe " + 
      "         name = 'frameMediaContent'" +
      "         src = '" + src + "'" + 
      "         width='" + width + "'" +
      "         height='" + height + "'" +
      "></iframe>";

      return obj;
}

MST.Media.Flash = function()
{
}

MST.Media.Flash.Create = function(src, width, height)
{
    var obj = 
      "<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='movieFlash'>" + 
      "  <param name='movie' value='" + src + "' />" + 
      "  <param name='quality' value='high' />" + 
      "  <param name='menu' value='true' />" +
      "  <param name='loop' value='0' />" +
      "  <param name='play' value='true'' />" +
      "  <embed" + 
      "    src='" + src + "'" + 
      "    width='" + width + "'" +
      "    height='" + height + "'" +
      "    play='true'" + 
      "    loop='0'" +
      "    quality='high'" +
      "    pluginspage='http://www.macromedia.com/go/getflashplayer'" +
      "    type='application/x-shockwave-flash'" + 
      "    menu='true'></embed>" +
      "</object>";

      return obj;
}

/******************************************************************************************************************************/
/****************************************** MEDIA END *************************************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** HOMEPAGE BANNER START *************************************************************/
/******************************************************************************************************************************/

MST.Controls.Banner = function()
{
}

MST.Controls.Banner.TimerId = null;
MST.Controls.Banner.TimerInterval = 100;

MST.Controls.Banner.NewContent = null;
MST.Controls.Banner.CurrentContent = null;

MST.Controls.Banner.CurrentButton = null;

MST.Controls.Banner.CurrentContentOpacity = 20;
MST.Controls.Banner.OpacityStep = 10;

MST.Controls.Banner.Init = function()
{
    var main_banner = document.getElementById("main_banner");
    if (main_banner != null)
    {
        this.CurrentContent = MST.Common.FindDirectChildById(main_banner, "silverlight");
    }

    var banner_tabs = document.getElementById("banner_tabs");
    if (banner_tabs != null)
    {
        this.CurrentButton = MST.Common.FindDirectChildById(banner_tabs, "tab_1");
        this.ChangeButton(this.CurrentButton);
    }
}

MST.Controls.Banner.SetOpacity = function(obj, opacity)
{
    if (obj.style.filter != null)
    {
        obj.style.filter = 'alpha(opacity = ' + opacity.toString() + ')';
    }
    else
    {
        obj.style.opacity = opacity / 100;
    }
}

MST.Controls.Banner.ChangeContent = function(bannerContent, newBtn)
{
    if (bannerContent != null
        && MST.Inited
        && bannerContent != this.CurrentContent
        && newBtn != this.CurrentButton)
    {
        this.FinishChangeProcess();

        this.StartChangeProcess(
            bannerContent
            , this.CurrentContent
            , newBtn);
    }
}

MST.Controls.Banner.StartChangeProcess = function(newContent, oldContent, newBtn)
{
    this.NewContent = newContent;
    this.CurrentContent = oldContent;

    this.ChangeButton(newBtn);

    this.NewContent.style.display = "block";

    this.TimerId = setInterval(
        this.OnIntervalElapsed
        , this.TimerInterval);
}

MST.Controls.Banner.ProceedChangeProcess = function()
{
    this.CurrentContentOpacity -= this.OpacityStep;

    if (this.CurrentContentOpacity < 0)
    {
        this.CurrentContentOpacity = 0;
    }

    this.SetOpacity(this.NewContent, 100 - this.CurrentContentOpacity);
    this.SetOpacity(this.CurrentContent, this.CurrentContentOpacity);

    if (this.CurrentContentOpacity <= 0)
    {
        this.FinishChangeProcess();
    }
}

MST.Controls.Banner.FinishChangeProcess = function()
{
    clearInterval(this.TimerId);
    
    this.CurrentContentOpacity = 100;
    
    if (this.NewContent != null)
    {
        this.SetOpacity(this.CurrentContent, 0);
        this.CurrentContent.style.display = "none";
        
        this.CurrentContent = this.NewContent;
        this.NewContent = null;
    }
}

MST.Controls.Banner.OnIntervalElapsed = function()
{
    MST.Controls.Banner.ProceedChangeProcess();
}

MST.Controls.Banner.OnClick_Tab = function(sender)
{
    var contentId = sender.attributes["contentid"].value;
    this.ChangeContent(
        this.FindContent(sender, contentId)
        , sender);
}

/******************************************************************************************************************************/
/****************************************** HOMEPAGE BANNER END ***************************************************************/
/******************************************************************************************************************************/
/******************************************************************************************************************************/
/****************************************** FORM START ************************************************************************/
/******************************************************************************************************************************/

MST.Controls.Form = function()
{
}

/************************** Form Common START **********************************************************************************/

MST.Controls.Form.GetForm = function(obj)
{
    return MST.Common.FindParentByTagType(obj, "FORM");
}

/************************** Form Validation START **********************************************************************************/

MST.Controls.Form.ShowError = function(obj, errorText, isShow)
{
    var td = MST.Common.FindParentByTagType(obj, "TD");
    var errorArea = MST.Common.FindDirectChildById(td, 'error_area');
    
    MST.Common.SetText(errorArea, errorText);
    
    if (isShow)
    {
        errorArea.style.display = "block";
    }
    else
    {
        errorArea.style.display = "none";
    }
}

MST.Controls.Form.IsFieldRequired = function(obj)
{
    if (obj.attributes == null)
    {
        return false;
    }

    var attribute = obj.attributes["required"];

    if (attribute != null
        && attribute.value != '')
    {
        return true;
    }
    else
    {
        return false;
    }
}

MST.Controls.Form.CheckRequiredFields = function(obj)
{
    var success = true;
    var requiredFields = 
        MST.Common.FindChildsByCriteria(
            this.GetForm(obj)
            , this.IsFieldRequired);

    for(var obj in requiredFields)
    {
        var obj = requiredFields[obj];
        
        if (obj.value == null)
        {
            continue;
        }
        
        if (obj.value == "")
        {
            success = false;
            this.ShowError(obj, obj.attributes["required"].value, true);
        }
        else
        {
            this.ShowError(obj, "", false);
        }
    }
    
    return success;
}

MST.Controls.Form.IsValid = function(obj)
{
    var success = true;
    
    if (!this.CheckRequiredFields(obj))
    {
        success = false;
    }

    return success;
}

/************************** Form Validation END **********************************************************************************/

MST.Controls.Form.Submit = function(obj)
{
    if (this.IsValid(obj))
    {
        var form = this.GetForm(obj);

        if (form != null)
        {
            MST.Form.DoPostBack(form);
        }
    }
}

MST.Controls.Form.OnSubmit = function(sender, event)
{
    if (this.IsValid(sender))
    {
        return true;
    }
    else
    {
        if (event
            && event.preventDefault)
        {
            event.preventDefault();
        }
        return false;
    }
}

MST.Controls.Form.OnSubmit_Clicked = function(sender, event)
{
    if (event
        && event.preventDefault)
    {
        event.preventDefault();
    }

    return this.Submit(sender);
}

/************************** Form Common END ************************************************************************************/

/************************** File Input Control START ***************************************************************************/

MST.Controls.Form.FileInput = function()
{
}

MST.Controls.Form.FileInput.GetWrapper = function(obj)
{
    return MST.Common.FindParentById(obj, 'file_input_wrapper');
}

MST.Controls.Form.FileInput.GetInputReal = function(obj)
{
    var wrapper = this.GetWrapper(obj);

    return MST.Common.FindDirectChildById(wrapper, 'file_input_real');
}

MST.Controls.Form.FileInput.GetInputText = function(obj)
{
    var wrapper = this.GetWrapper(obj);
    var textWrapper = MST.Common.FindDirectChildById(wrapper, 'file_input_text_wrapper');
    
    return MST.Common.FindDirectChildById(textWrapper, 'file_input_text');
}

MST.Controls.Form.FileInput.ShowDialog = function(obj)
{
    //this.GetInputReal(obj).fireEvent('click');
}

MST.Controls.Form.FileInput.OnTextClicked = function(sender)
{
    this.ShowDialog(sender);
}

MST.Controls.Form.FileInput.OnButtonClicked = function(sender)
{
    this.ShowDialog(sender);
}

MST.Controls.Form.FileInput.OnFileSelected = function(sender)
{
    this.GetInputText(sender).value = sender.value;
}

/************************** File Input Control END ********************/
/******************************************************************************************************************************/
/****************************************** FORM END **************************************************************************/
/******************************************************************************************************************************/
