﻿/// <reference path="jquery.intellisense.js"/>
// =====================
// Show Preview Panel    
// =====================
function ShowPreviewPanel(elid, url) {
  ClearAlertMsg();
  // check for diabled preview
  if (document.getElementById(elid).className=='lightEditActionDisabled'){
    SetAlertMsg('Preview feature not available');
  }
  else {
    if (url.toString().substring(0, 22) == 'http://www.youtube.com'){
        // if we are on the default.aspx page then mark the report as viewed
        if (document.location.pathname.toLowerCase() == '/default.aspx') {
            BNAlerts.Services.MarkAsViewed(elid);
        }
        //show youtube preview
        ShowYouTubePanel(elid, url)
    }
    else{
        // set the src
        document.getElementById('framPreview').src = url;
        // set the location of the panel
        yuiPreviewPanel.cfg.setProperty("context", [elid, "tr", "br"]);
        // show the panel
        yuiPreviewPanel.show();
        // swap the static marketing content
        SwapMarketingFlash('static');    
    }
  }
} 
// =====================
// Hide Preview Panel    
// =====================
function ClosePreviewPanel(action) {
    // set the source back to "Loading..."
    document.getElementById('framPreview').src = '../misc/loading.aspx';
    // hide the panel
    yuiPreviewPanel.hide();
    // swap the static marketing content
    SwapMarketingFlash('flash');     
}
//======================
// Clear Select Options
//======================
function ClearSelectOptions(sel) {
  // NOTE: sel is a jQuery object  
  sel.html('');
};
//======================
// Add Select Option
//======================
function AddSelectOption(sel,val,text) {
  // NOTE: sel is a jQuery object  
  var opt = document.createElement('option');
  opt.text = text;
  opt.value = val;
  try {
    sel[0].add(opt, null); // standards compliant; doesn't work in IE
  }
  catch(ex) {
    sel[0].add(opt); // IE only
  }
};
// clear watermarks in textboxes
function ClearWatermark(textbox, testClass, switchClass) {
  if (textbox.className == testClass) {
    textbox.value = "";
    textbox.className = switchClass;
  }
}
//======================================
// set the selected option by it's value
//======================================
function SelectOptionByValue(select,val) {
  for (var i=0; i<select[0].options.length; i++) {
    if (select[0].options[i].value==val) {
      select[0].selectedIndex=i;
    }
  }
}
//==========================
// Get Selected Option Value
//==========================
function GetSelectedOptionValue(sel){
  // NOTE: sel is a jQuery object  
  var val;
  try {
    var pop=sel[0];
    var index=pop.selectedIndex;
    val=pop[index].value;
  }
  catch(ex){
    val='';
  }
  return val;
}
