/**
  * Upload Dialog
  * Still requires a hidden div on the calling page
  * with the multipart form html
  */
  sks_AppUpload = function(icon) 
    {
        // CONSTRUCTOR for 'jt_AppAlert' object - EXTENDS 'jt_DialogBox'
        if (arguments.length==0) return;
        this.base = jt_DialogBox;
        this.base(true);

        var dialogTable = document.createElement('table');
        dialogTable.setAttribute('cellSpacing', '0');
        dialogTable.setAttribute('cellPadding', '0');
        dialogTable.setAttribute('border', '0');

        var tBody = document.createElement('tbody');
        var row = document.createElement('tr');
        var cell = document.createElement('td');
        cell.setAttribute("vAlign", "top");
        
        
        var eldiv = document.createElement('div');
        eldiv.setAttribute('class', 'dialog_icon'); 
        
        
        this.iconImage = document.createElement('img');
        this.iconImage.setAttribute('src', sks_imagePath + "/" + icon);
        this.iconImage.setAttribute('border', '0');
        eldiv.appendChild(this.iconImage);
        cell.appendChild(eldiv);   
        row.appendChild(cell);

        this.contentCell = document.createElement('td');
        this.contentCell.className = "ContentArea";
        row.appendChild(this.contentCell);
        tBody.appendChild(row);
        dialogTable.appendChild(tBody);
        this.contentArea.appendChild(dialogTable);

        this.buttonDIV = document.createElement('div');
        this.buttonDIV.style.marginTop = "15px";
        this.buttonDIV.setAttribute("align", "center");
        this.buttonDIV.setAttribute("class", "button_container");
        this.contentArea.appendChild(this.buttonDIV);
        sks_AppAlert.addButton(this, 'cancel', 1 );

    }
    sks_AppUpload.prototype = new jt_DialogBox(); 

      
    sks_AppUpload.prototype.setContent = function(htmlContent) 
    {
        this.contentCell.innerHTML = htmlContent;
    }

    sks_AppUpload.prototype.setIcon = function(icon) 
    {
        this.iconImage.src = sks_imagePath + "/" + icon;
    }


/**
  * Alert Dialog
  * This is the base dialog for the confirm and prompt dialogs 
  */



sks_AppAlert = function(icon, click_id) 
{
    // CONSTRUCTOR for 'jt_AppAlert' object - EXTENDS 'jt_DialogBox'
    if (arguments.length==0) return;
    this.base = jt_DialogBox;
    this.base(true);

    var dialogTable = document.createElement('table');
    dialogTable.setAttribute('cellSpacing', '0');
    dialogTable.setAttribute('cellPadding', '0');
    dialogTable.setAttribute('border', '0');

    var tBody = document.createElement('tbody');
    var row = document.createElement('tr');
    var cell = document.createElement('td');
    cell.setAttribute("vAlign", "top");
    
    
    var eldiv = document.createElement('div');
    eldiv.setAttribute('class', 'dialog_icon'); 
    
    
    this.iconImage = document.createElement('img');
    this.iconImage.setAttribute('src', sks_imagePath + "/" + icon);
    this.iconImage.setAttribute('border', '0');
    eldiv.appendChild(this.iconImage);
    cell.appendChild(eldiv);   
    row.appendChild(cell);

    this.contentCell = document.createElement('td');
    this.contentCell.className = "ContentArea";
    row.appendChild(this.contentCell);
    tBody.appendChild(row);
    dialogTable.appendChild(tBody);
    this.contentArea.appendChild(dialogTable);



    this.buttonDIV = document.createElement('div');
    this.buttonDIV.style.marginTop = "15px";
    this.buttonDIV.setAttribute("align", "center");
    this.buttonDIV.setAttribute("class", "button_container");
    this.contentArea.appendChild(this.buttonDIV);
    sks_AppAlert.addButton(this, 'ok', 1, click_id );

}
sks_AppAlert.prototype = new jt_DialogBox(); 

  
sks_AppAlert.prototype.setContent = function(htmlContent) 
{
    this.contentCell.innerHTML = htmlContent;
}

sks_AppAlert.prototype.setIcon = function(icon) 
{
    this.iconImage.src = sks_imagePath + "/" + icon;
}

/**
  * Confirm Dialog
  * Builds off of the Alert dialog
  */
  
sks_AppConfirm = function(icon, callOK, callCancel) 
{
    // CONSTRUCTOR for 'jt_AppConfirm' object - EXTENDS 'jt_AppAlert'
    if (arguments.length==0) return;
    this.base = sks_AppAlert;
    this.base(icon);
    this.callOK = callOK;
    this.callCancel = callCancel;
    // add the cancel button to the button div created in the appalert constructor
    sks_AppAlert.addButton(this, 'cancel', 2);
}
sks_AppConfirm.prototype = new sks_AppAlert(); 

sks_AppConfirm.prototype.askUser = function(htmlContent) 
{
    this.setContent(htmlContent);
    this.show();
}

/**
  * Prompt Dialog
  * Builds off of the Alert dialog
  */
sks_AppPrompt = function(icon, callOK, callCancel, cssClass) 
{
      // CONSTRUCTOR for 'jt_AppPrompt' object - EXTENDS 'jt_AppConfirm'
      if (arguments.length==0) return;
      this.base = sks_AppConfirm;
      this.base(icon, callOK, callCancel);
      this.returnData = new Object();
      this.fInput = document.createElement('input');
      this.fInput.type = "text";
      if (cssClass) this.fInput.className = cssClass;
      this.fInput.appDialog = this;
      this.fInput.onkeypress = sks_AppPrompt.keyPress;
}

sks_AppPrompt.prototype = new sks_AppConfirm();
sks_AppPrompt.superClass = sks_AppConfirm.prototype;

sks_AppPrompt.prototype.askUser = function(htmlContent, stDefault) 
{
    this.setContent(htmlContent);
    this.fInput.value = stDefault;
    this.contentCell.appendChild(this.fInput);
    this.show();
    this.fInput.focus();
}

sks_AppPrompt.prototype.focus = function() 
{
    this.fInput.focus();
}

sks_AppPrompt.prototype.hide = function(ok) 
{
    if (ok) this.returnData.value = this.fInput.value;
    sks_AppPrompt.superClass.hide.call(this, ok);
}

sks_AppPrompt.keyPress = function(e) 
{
    if (!e) e = window.event;
    var node = e.target ? e.target : e.srcElement;
    var key = e.keyCode ? e.keyCode : e.which;
    if (key == 13) node.appDialog.hide(true);
    if (key == 27) node.appDialog.hide();
}
    
/**
  * Add button function
  */
sks_AppAlert.addButton = function(parent, name, buttonNum, id) 
{
 
    var buttonAnchor = document.createElement('a');
    buttonAnchor.setAttribute("href", "javascript:void(0);");
    buttonAnchor.setAttribute("class", "button_anchor");
    if( typeof( id ) != "undefined" ) {
    buttonAnchor.setAttribute("id", id );
    }
    buttonAnchor.appDialog = parent;


    var button = document.createElement('img');
    button.setAttribute('class', "button_image" );
    button.setAttribute('id', "button_image_" + name);  
    button.setAttribute('src', sks_imagePath + "/blank.gif");
    button.setAttribute('border', '0');   
    button.onclick = sks_AppAlert.clickLink; 
    button.linkNum = buttonNum; 

    buttonAnchor.appendChild(button);
    parent.buttonDIV.appendChild(buttonAnchor); 
 }

sks_AppAlert.clickLink = function(e) 
{
    if (!e) e = window.event;
    var node = e.target ? e.target : e.srcElement;
    var linkNum = node.linkNum;
    var count = 0;
    while ((node != null) && (count < jt_DialogBox.maxDepth)) 
    {
        if (node.appDialog) {
            switch (linkNum) {
                case 1: 
                {
                    node.appDialog.hide(true);
                    break;
                }
                case 2: 
                {
                    node.appDialog.hide();
                    break;
                }
            }
            return false;
        }
        node = node.parentNode;
        count++;
    }
    return false;
 }


