﻿// JScript File

function ShowHideLayer(subMenu, action)
{
    if (action == "show")
    {
        document.getElementById(subMenu).style.display = "block";
    }
    else
    {
        document.getElementById(subMenu).style.display = "none";
    }
}
function DisplayViewVideoTitle(cellControlId)
{
      var width = 880;
      var height = 600;
      var top = (screen.height - height) / 2;
      var left = (screen.width - width) / 2;
      url = 'TeachVideoDisplay.aspx?CellId='+cellControlId;
      window.open(url,"CourseInfo","width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");           
}
function userLogin(rtPath)
{
     if(!confirm("購買商品之前請登錄，是否馬上登錄？")){
        return false;
     }else{
       location.href=rtPath;
     }
}
function sc(casenum, casetype)
 {
   switch (casetype)
   {
    case "over":
        document.getElementById(casenum).style.backgroundColor = "#BBDDFF";
        document.getElementById(casenum).style.border = "solid 1px #3399FF";
        break;
    case "out":
        document.getElementById(casenum).style.backgroundColor = "#FFFFFF";
        document.getElementById(casenum).style.border = "solid 1px #FFFFFF";
        break;
    }
  }
function PlayMediaVideoFile()
  {
      var s="<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" id=\"v_player\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715\" type=\"application/x-oleobject\" standby=\"Loading Microsoft Windows Media Player components...\" width=\"310\" height=\"290\">";
     s=s+"<param id=\"v_file\" name=\"Filename\" value=\"../UploadFiles/12345678.wmv\"></param>";
     s=s+"<param name=\"AutoStart\" value=\"false\" />";
     s=s+"<param name=\"StretchToFit\" value=\"true\" />";
     s=s+ "<param name=\"EnableFullScreenControls\" value=\"1\" />";
     s=s+ "<param name=\"EnableFullScreenControls\" value=\"1\" />";
     s=s+ "<param name=\"Volume\" value=\"0\">";
     s=s+ "<param name=\"ShowStatusBar\" value=\"1\"/>"; 
     s=s+" </object>"; 
     document.getElementById("bullitinView").innerHTML=s; 
 }
function PlayBulltinInfo(infoId)
{
   document.getElementById("bullitinView").style.backgroundColor='#f0f0f0';
   
   var datatable = ForeApp_PublicSite_Default.GetBullitinValue(infoId).value;
   var videoName="";
   if (datatable.Rows.length > 0)
   {
        videoName=datatable.Rows[0].videoFileName;               
   }
   if(videoName.toLowerCase().indexOf(".flv")>-1){
     
         PlayBulltinInfoFlash(videoName);
   
   }else{      
       var s="<object classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" id=\"v_player\" codebase=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715\" type=\"application/x-oleobject\" standby=\"Loading Microsoft Windows Media Player components...\" width=\"310\" height=\"290\">";
       s=s+"<param id=\"v_file\" name=\"Filename\" value=\"../UploadFiles/"+videoName+"\"></param>";
       s=s+"<param name=\"AutoStart\" value=\"true\" />";
       s=s+"<param name=\"StretchToFit\" value=\"true\" />";
       s=s+ "<param name=\"EnableFullScreenControls\" value=\"1\" />";
       s=s+ "<param name=\"EnableFullScreenControls\" value=\"1\" />";
       s=s+ "<param name=\"Volume\" value=\"0\">";
       s=s+ "<param name=\"ShowStatusBar\" value=\"1\"/>"; 
       s=s+" </object>"; 
       document.getElementById("bullitinView").innerHTML=s; 
   }
 
}
       
function PlayBulltinInfoFlash(videoName){
     var s="<object type=\"application/x-shockwave-flash\" width=\"310\" height=\"290\" wmode=\"transparent\" data=\"flvplayer.swf?file=../UploadFiles/"+videoName+"\" />";
     s=s+"<param name=\"movie\" value=\"flvplayer.swf?autostart=false&file=../UploadFiles/"+videoName+"\" />";
     s=s+"<param name=\"wmode\" value=\"transparent\" />";
     s=s+"</object>";
     document.getElementById("bullitinView").innerHTML=s;
}

      
function DisplaySpecialVideoById(cellControlId)
{
     var width = 400;
     var height = 400;
     var top = (screen.height - height) / 2;
     var left = (screen.width - width) / 2;
     url = 'SpeicalVideoDisplay.aspx?CellId='+cellControlId;
     window.open(url,"CourseInfo","width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
}
function DisplayCourse(cellControlId)
{
     var width = 880;
     var height = 600;
     var top = (screen.height - height) / 2;
     var left = (screen.width - width) / 2;
     url = '/public/courseshow.aspx?course='+cellControlId;
     window.open(url,"CourseInfo","width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
}
       
function DisplayViewVideo(cellControlId)
{
      var width = 880;
      var height = 600;
      var top = (screen.height - height) / 2;
      var left = (screen.width - width) / 2;
      url = 'TeachVideoDisplay.aspx?CellId='+cellControlId;
      window.open(url,"CourseInfo","width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no");
     // OpenDialogHelper.openModalDlg(url, {mode : "new"}, width, height);            
}
function Change(infoId)
{
     var datatable = ForeApp_PublicSite_Default.GetVideoValue(infoId).value;
     if (datatable.Rows.length > 0)
     {
           PlayMediaVideos(document.getElementById("videoFile"),datatable.Rows[0].video_file_name);  
     }
}