﻿// JScript File
var PLACE_HOLDER_ID = "popupHolder";
var isPopupDisplayed = false;
function Popup()
{
    // define object properties
    this.div = document.createElement('div');
    this.div.id = PLACE_HOLDER_ID;
    this.width = '200px';
    this.height = '100px';
    this.position = 'absolute';
    this.y = '10px';
    this.x = '10px';
    this.padding = '2px';
    this.border = '1px solid #989898';
    this.backgroundColor = '#ffffff';
    this.overflow = "auto";
    this.body = '';
    this.html = '';
    this.showCloseButton = true;
    // define 'display()' method
    this.display = function(){
        this.div.style.width = this.width;
        this.div.style.height = this.height;
        this.div.style.position = this.position;
        this.div.style.top = this.y;
        this.div.style.left = this.x;
        this.div.style.padding = this.padding;
        this.div.style.border = this.border;
        this.div.style.background = this.backgroundColor;
        this.div.style.zIndex = 51200;
        this.div.style.overflow = this.overflow;
        this.html = '<div>';
        if (this.showCloseButton)
        {
            this.html +='    <div style="float:right;height:15px;cursor: pointer" onclick="HidePopup();"><img src="../../images/close_tiptool.jpg"></div>'
        }
        this.html +='    <div style="clear:right">';
        this.html +=        this.body;
        this.html +='    </div>';
        this.html +='</div>';
        this.div.innerHTML = this.html;
        document.getElementsByTagName('body')[0].appendChild(this.div);
        this.div.style.display = '';//'block';
    }
}

//------------------------------------------------------------------------------------------

function ColorPicker(holderObj)
{
    var coors = FindPos(holderObj);
    this.x = coors[0] + 'px';
    this.y = coors[1] + holderObj.offsetHeight + 'px';
    this.width = '95px';
    this.height = '60px';
    
    var colors = new Array(	"FFFFFF", "CDCDCD", "999999", "666666", "000000",
							"006A51", "FFF200", "ED1924", "FF00FF", "048CD6");
						
	var htmlBody = "<div>";						
	for (var i = 0; i < colors.length; i++)
	{
		htmlBody += "  <div style=\"width:12px;height:12px;border:1px solid #808080;margin:2px;float:left;cursor:pointer;background-color:#" + colors[i] + "\" onclick=\"SetSlideProperties('color', '" + colors[i] + "');HidePopup();\"></div>";
		if ((((i + 1) % 5) == 0) && (i != colors.length))
		{
			htmlBody += "</div>";
			htmlBody += "<div style=\"clear:left\">";
		}
	}
	this.body = htmlBody;
}   
ColorPicker.prototype = new Popup();

//------------------------------------------------------------------------------------------

function ShowColorPicker(holderObj)
{
	var oColorPicker = new ColorPicker(holderObj);
	if (isPopupDisplayed)
	{
	    HidePopup();
	}
	oColorPicker.display();
	isPopupDisplayed = true;
}

//------------------------------------------------------------------------------------------

function AlignPicker(holderObj)
{
    var coors = FindPos(holderObj);
    this.x = coors[0] + 'px';
    this.y = coors[1] + holderObj.offsetHeight + 'px';
    this.width = '140px';
    this.height = '80px';
    
	var htmlBody = "<div style=\"margin-left:10px\">";
	    htmlBody +=     "<div style=\"float:left;cursor:pointer\" onclick=\"SetSlideProperties('align', 'left');HidePopup();\"><img src=\"../images/align_left_button.PNG\" onmouseover=\"SelectAlign(this, 'select');\" onmouseout=\"SelectAlign(this, 'unselect');\"></div>";
	    htmlBody +=     "<div style=\"float:left;cursor:pointer\" onclick=\"SetSlideProperties('align', 'center');HidePopup();\"><img src=\"../images/align_center_button.PNG\" onmouseover=\"SelectAlign(this, 'select');\" onmouseout=\"SelectAlign(this, 'unselect');\"></div>";
	    htmlBody +=     "<div style=\"float:left;cursor:pointer\" onclick=\"SetSlideProperties('align', 'right');HidePopup();\"><img src=\"../images/align_right_button.PNG\" onmouseover=\"SelectAlign(this, 'select');\" onmouseout=\"SelectAlign(this, 'unselect');\"></div>";
	    htmlBody += "</div>";
	    	
	this.body = htmlBody;
}   
AlignPicker.prototype = new Popup();

//------------------------------------------------------------------------------------------

function ShowAlignPicker(holderObj)
{
	var oAlignPicker = new AlignPicker(holderObj);
	if (isPopupDisplayed)
	{
	    HidePopup();
	}
	oAlignPicker.display();
	isPopupDisplayed = true;
}

//------------------------------------------------------------------------------------------

function FontPicker(holderObj)
{
    var coors = FindPos(holderObj);
    this.x = coors[0] + 'px';
    this.y = coors[1] + holderObj.offsetHeight + 'px';
    this.width = '150px';
    this.height = '200px';
    this.padding = '';
    this.border = '';
    this.backgroundColor = '';
    this.overflow = "hidden";
    this.showCloseButton = false;
    
	var htmlBody = "<select class=\"comboBox\" style=\"width:140px\" onchange=\"SetSlideProperties('font', this.options[this.selectedIndex].value);HidePopup();\" id=\"fontList\">";
        htmlBody += "    <option value=\"_arial\">Arial</option>";
        htmlBody += "    <option value=\"_comic\">Comic Sans MS</option>";
        htmlBody += "    <option value=\"_gara\">Garamond</option>";
        htmlBody += "    <option value=\"_gill\">Gill Sans MT</option>";
        htmlBody += "    <option value=\"_modern\">Modern</option>";
        htmlBody += "    <option value=\"_script\">Script</option>";
        htmlBody += "    <option value=\"_tahoma\">Tahoma</option>";
        htmlBody += "   <option value=\"_verd\">Verdana</option>";
        htmlBody += "</select>";
                    
	this.body = htmlBody;
}   
FontPicker.prototype = new Popup();

//------------------------------------------------------------------------------------------

function ShowFontPicker(holderObj)
{
	var oFontPicker = new FontPicker(holderObj);
	if (isPopupDisplayed)
	{
	    HidePopup();
	}
	oFontPicker.display();
	isPopupDisplayed = true;
}

//------------------------------------------------------------------------------------------

function OpacityPicker(holderObj)
{
    var coors = FindPos(holderObj);
    this.x = coors[0] + 'px';
    this.y = coors[1] + holderObj.offsetHeight + 'px';
    this.width = '70px';
    this.height = '200px';
    this.padding = '';
    this.border = '';
    this.backgroundColor = '';
    this.overflow = "hidden";
    this.showCloseButton = false;
    
	var htmlBody =  "<select class=\"comboBox\" style=\"width:70px\" onchange=\"SetSlideProperties('alpha', this.options[this.selectedIndex].value);HidePopup();\" id=\"opacityValues\">";
        htmlBody += "     <option value=\"10\">10%</option>";
        htmlBody += "     <option value=\"20\">20%</option>";
        htmlBody += "     <option value=\"30\">30%</option>";
        htmlBody += "     <option value=\"40\">40%</option>";
        htmlBody += "     <option value=\"50\">50%</option>";
        htmlBody += "     <option value=\"60\">60%</option>";
        htmlBody += "     <option value=\"70\">70%</option>";
        htmlBody += "     <option value=\"80\">80%</option>"; 
        htmlBody += "     <option value=\"90\">90%</option>"; 
        htmlBody += "     <option value=\"100\" selected>100%</option>"; 
        htmlBody += "</select>";
           
	this.body = htmlBody;
}   
OpacityPicker.prototype = new Popup();

//------------------------------------------------------------------------------------------

function ShowOpacityPicker(holderObj)
{
    var oOpacityPicker = new OpacityPicker(holderObj);
	if (isPopupDisplayed)
	{
	    HidePopup();
	}
	oOpacityPicker.display();
	isPopupDisplayed = true;
}

//------------------------------------------------------------------------------------------

function HidePopup()
{
    if (isPopupDisplayed)
    {
        isPopupDisplayed = false;
        document.getElementsByTagName('body')[0].removeChild(document.getElementsByTagName("body")[0].lastChild);
    }
}

//------------------------------------------------------------------------------------------

function wResetTabsView()
{
    document.getElementById('ctl00_ContentPlaceHolder1_imgFootageStep').src = document.getElementById('ctl00_ContentPlaceHolder1_imgFootageStep').src.replace("tab_selected", "tab");
    document.getElementById('ctl00_ContentPlaceHolder1_imgTextStep').src = document.getElementById('ctl00_ContentPlaceHolder1_imgTextStep').src.replace("tab_selected", "tab");
    document.getElementById('ctl00_ContentPlaceHolder1_imgSlideStep').src = document.getElementById('ctl00_ContentPlaceHolder1_imgSlideStep').src.replace("tab_selected", "tab");
    document.getElementById('ctl00_ContentPlaceHolder1_imgAudioStep').src = document.getElementById('ctl00_ContentPlaceHolder1_imgAudioStep').src.replace("tab_selected", "tab");
    document.getElementById('ctl00_ContentPlaceHolder1_imgFinishStep').src = document.getElementById('ctl00_ContentPlaceHolder1_imgFinishStep').src.replace("tab_selected", "tab");
}

//------------------------------------------------------------------------------------------

function wSelectTab(tabObj)
{
    wResetTabsView();
    //var className;
    tabObj.src = tabObj.src.replace("tab", "tab_selected");
    /*switch (tabId)
    {
        case 'footageStep' :
            tabObj.src = tabObj.src.replace("tab", "tab_selected");
            break;
        case 'textStep' :
            className = 'wizardTextTabTabSelected';
            break;
        case 'slideStep' :
            className = 'wizardSlideTabSelected';
            break;
        case 'audioStep' :
            className = 'wizardAudioTabSelected';
            break;
        case 'finishStep' :
            className = 'wizardFinishTabSelected';
            break;
    }
    document.getElementById(tabId).className = className;*/
}

//----------------------------------------------------------------------------------------------

function SelectAlign(obj, action)
{
    if (action == 'select')
    {
        obj.src = obj.src.replace('button', 'hover_button');
    }
    else
    {
        obj.src = obj.src.replace('hover_button', 'button');
    }
}

//----------------------------------------------------------------------------------------------

function getTextValue(textIndex)
{
   try
    {
        //var footageGalleryWin = GetRadWindow();
        //var oDictionaryEntry = footageGalleryWin.Argument;
        //var mixerPage = footageGalleryWin.BrowserWindow;
        var xml = getXML();
        var textValue;
        
        try //Internet Explorer
        {
          var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
          xmlDoc.async = "false";
          xmlDoc.loadXML(xml);
        }
        catch(e)
        {
            try //Firefox, Mozilla, Opera, etc.
            {
                var parser = new DOMParser();
                xmlDoc = parser.parseFromString(xml,"text/xml");
            }
            catch(e)
            {
                alert(e.message);
                return;
             }
        }
        textValue = xmlDoc.getElementsByTagName("Slide")[textIndex].getAttributeNode("text").nodeValue;
        
        
        var textObjId;
        if (textIndex == 2)
        {
            textObjId = 'text1';
        }
        else
        {
            textObjId = 'text2';
        }
        document.getElementById(textObjId).value = unescape(textValue);
        
    }
    catch(err)
    {
    
    }
}



