﻿var Shell = 1;
var Color_Mode = 100;
var store = "No Data Stored";
var dir = "@supremesearch.net";
var Rurl = "NA"; var Rwidth = "NA"; var Rheight = "NA";

//Desktop
var Desktop = "1";
var New_File = "1";
var IconClass = "Icon";

function Terminal(){
  var Input = document.T_form.Input.value;
  var wordcount = Input.split(" ").length;

  //Display
  document.T_form.Display.value += Shell + "[" + User + dir + "]$ " + Input + "\n";

  //Standard Commands 1
  if (Input.toLowerCase() == "help"){Help();}
  else if (Input.toLowerCase() == "close"){document.getElementById('Term').style.display = 'none'; displaysplash();}
  else if (Input.toLowerCase() == "logname"){document.T_form.Display.value += User + "\n";}
  else if ((Input.toLowerCase() == "ls") || (Input.toLowerCase() == "cd")){document.T_form.Display.value += User + dir + "\n";}
  else if (Input.toLowerCase() == "sh"){Shell++;}

  //Search
  else if (Input.toLowerCase().indexOf("srch") != -1) {
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      var Final_Input = New_Input.replace("srch ","");
      window.open("Search.php?User_Input=" + Final_Input, '','height=500,width=770, scrollbars=yes, resizable=yes, location=yes');
    }else{document.T_form.Display.value += "Must Specify Search Term\n";}
  }

  //Echo
  else if (Input.toLowerCase().indexOf("echo") != -1) {
    var New_Input=Input.toLowerCase();
    var Final_Input = New_Input.replace("echo ","");
    document.T_form.Display.value += Final_Input + "\n";
  }
  
  //Date
  else if ((Input.toLowerCase() == "date") || (Input.toLowerCase() == "time")){
    var suffix="AM";
    var today = new Date()
    var Greeting = "Good ";
    var hours = today.getHours()
    var minutes = today.getMinutes()
    if (hours > 11){suffix="PM";} 
    if (hours > 18){Greeting += "Evening!";}
    else if (hours >12){Greeting += "Afternoon!";}
    else{Greeting += "Morning!";}

    hours = hours % 12;
    if (hours == 0){hours = 12;}
    if (minutes < 10){minutes="0"+minutes;}
    document.T_form.Display.value += weekday[today.getDay()] + ' ' + month + '/' + day + '/' + year + ", " + hours + ":" + minutes + " " + suffix + "\n";
    document.T_form.Display.value += Greeting + "\n";
  }

  //Goto URL
  else if (Input.toLowerCase().indexOf("fopen") != -1){
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      var Final_Input = New_Input.replace("fopen ","");
      Final_Input = Final_Input.replace("ping ","");
      window.open(Final_Input,'mywindow','menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,location=yes,width=450,height=400');
    }else{document.T_form.Display.value += "Must Specify URL\n";}
  }

  //Ping
  else if (Input.toLowerCase().indexOf("ping") != -1){
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      Final_Input = New_Input.replace("ping ","");
      var w = window.open('', 'Ping', 'width=500,height=50,scrollbars=yes');; 
      w.document.writeln('<SCRIPT LANGUAGE="JavaScript">\r\n');
      w.document.writeln('var beforeload = (new Date()).getTime();\r\n');
      w.document.writeln('function pageloadingtime(){');
      w.document.writeln('afterload = (new Date()).getTime();');
      w.document.writeln('secondes = (afterload-beforeload)/1000;');
      w.document.writeln('document.getElementById("loadingtime").innerHTML += "<big><font color=\'red\'>(This IP took " + secondes + " second(s) to load.)</font></big>";');
      w.document.writeln('}\r\n');
      w.document.writeln('<\/SCRIPT><font color="red"><big>Pinging '+Final_Input+' ...</big></font><div id="loadingtime"><\/div>\r\n');
      w.document.writeln('<IFRAME src="'+Final_Input+'" WIDTH="0" HEIGHT="0" ONLOAD="pageloadingtime()"></IFRAME>');
      w.document.close(); document.getElementById('Display').value += "Please Wait...\n";
    }else{document.T_form.Display.value += "Must Specify IP or URL\n";}
  }

  //Change Username
  else if (Input.toLowerCase().indexOf("cguser") != -1) {
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      User = New_Input.replace("cguser ",""); Show_User();
    }else{document.T_form.Display.value += "Must Specify Username\n";}
  }

  //Standard Commands 2
  else if (Input.toLowerCase() == "refresh"){Refresh();}
  else if (Input.toLowerCase() == "reboot"){top.location.href="boot.htm";}
  else if (Input.toLowerCase() == "halt"){halt();}
  else if (Input.toLowerCase() == "notepad"){window.open('Web-App/NotePad.php', '','height=500,width=720, scrollbars=yes, resizable=yes, menubar=yes');}
  else if (Input.toLowerCase() == "wordpad"){window.open('Web-App/WordPad.htm', '','height=500,width=750, scrollbars=yes, resizable=yes, menubar=yes');}
  else if (Input.toLowerCase() == "cal"){window.open('Calendar.html', '','height=280,width=340');}
  else if (Input.toLowerCase() == "uname"){document.T_form.Display.value += uname + "\n";}
  else if (Input.toLowerCase() == "clr"){document.T_form.Display.value = "";}
  else if (Input.toLowerCase() == "mail"){window.open('Web-App/E-mail.html', '','height=400,width=620, scrollbars=yes');}

  //Storetxt
  else if (Input.toLowerCase().indexOf("storetxt") != -1) {
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      store = New_Input.replace("storetxt ",""); 
    }else{document.T_form.Display.value += "Must Specify Text\n";}
  }

  //Displaytxt
  else if (Input.toLowerCase() == "displaytxt"){document.T_form.Display.value += store + "\n";}

  //sbar
  else if (Input.toLowerCase().indexOf("sbar") != -1) {
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      var Final_Input = New_Input.replace("sbar ","");
      document.form.search.value = Final_Input;
    }else{document.T_form.Display.value += "Must Specify Text\n";}
  }

  //calc
  else if  (Input.toLowerCase() == "calc"){window.open('Web-App/Scientific Calculator.html', 'Calculator','height=480,width=600, scrollbars=yes');}

  //mkdir
  else if (Input.toLowerCase().indexOf("mkdir") != -1) {
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      var Input2 = New_Input.split(" ");

      //If directory already existed
      if (dir.toLowerCase().indexOf(Input2[1].toLowerCase()) != -1) {
        document.T_form.Display.value += "Directory already existed. \n";
      }
        else
      {
        var Final_Input = New_Input.replace("mkdir ","");
        Final_Input = Final_Input.replace(/\s+/g,"_");	//Del Blank Spaces
        dir += "/" + Final_Input;
      }
    }else{document.T_form.Display.value += "Must Specify dir\n";}
  }

  //rmdir
  else if (Input.toLowerCase().indexOf("rmdir") != -1) {
    if (wordcount > 1){
      if (Input.toLowerCase().indexOf("/") != -1) {
        var New_Input=Input.toLowerCase();
        var Input2 = New_Input.split(" ");
        var Final_Input = dir.replace(Input2[1],"");
        dir = Final_Input;
      }
        else
      {
        document.T_form.Display.value += "Directory not deleted must include \"/\" before file name.\n";
      }
    }else{document.T_form.Display.value += "Must Specify /dir\n";}
  }

  //Standard Commands 3
  else if (Input.toLowerCase() == "xpaint"){window.open('Web-App/Paint.htm', '','height=500,width=650, scrollbars=yes, resizable=yes, menubar=yes');}
  else if (Input.toLowerCase() == "webapp"){App_List();}
  else if (Input.toLowerCase() == "vga"){document.T_form.Display.value += screen.width + " x " + screen.height + "\n";}
  else if (Input.toLowerCase() == "brname"){document.T_form.Display.value += navigator.appName + "\n";}
  else if (Input.toLowerCase() == "deltree"){dir = "@www.supremesearch.net";}

  //dsktop
  else if (Input.toLowerCase().indexOf("dsktop") != -1) {
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      var Final_Input = New_Input.replace("dsktop ","");
      document.WallPaper.URL.value = Final_Input;
      New_WallPaper()
    }else{document.T_form.Display.value += "Must Specify URL\n";}
  }

  //cgcolor
  else if (Input.toLowerCase().indexOf("cgcolor") != -1) {
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      var Final_Input = New_Input.replace("cgcolor ","");
      document.getElementById('Display').style.backgroundColor = Final_Input;
    }else{document.T_form.Display.value += "Must Specify Color\n";}
  }

  //txcolor
  else if (Input.toLowerCase().indexOf("txcolor") != -1) {
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      var Final_Input = New_Input.replace("txcolor ","");
      document.getElementById('Display').style.color = Final_Input;
    }else{document.T_form.Display.value += "Must Specify Color\n";}
  }

  //Script
  else if (Input.toLowerCase().indexOf("[script]") != -1) {
    if (wordcount > 1){
      var New_Input=Input.toLowerCase();
      var Final_Input = New_Input.replace("[script] ","");
      var w = window.open(); w.document.writeln('<script language="JavaScript">' + Final_Input + '<\/script>');
      w.document.close();
      document.getElementById('Display').value += "Executing Script ...\n";
    }else{document.T_form.Display.value += "Must Specify Command\n";}
  }

  //word count
  else if (Input.toLowerCase().indexOf("wc") != -1) {
    if (wordcount > 1){ wordcount = wordcount - 1;
      document.getElementById('Display').value += wordcount + " words\n";
    }else{document.T_form.Display.value += "Must enter more words\n";}
  }

  //AI
  else if (Input.toLowerCase().indexOf("ai") != -1) {loadwindow('Web-App/AI.htm',750,350); document.getElementById('Term').style.display = 'none';}

  //Blank & Error
  else if (Input.toLowerCase() == ""){}
  else{document.T_form.Display.value += "Command not found: \"" + Input + "\"\n";}

  document.T_form.Display.value += "\n";
  if (Input.toLowerCase() != "help"){document.getElementById('Display').scrollTop=document.getElementById('Display').scrollHeight;}
  document.T_form.Input.value = "";
  return false;
}

function deleteChar(input) {
  input.value = input.value.substring(0, input.value.length - 1)
}

function Help(){
  document.T_form.Display.value = "System Help \n\n" 
  + "brname\t\tDisplay web browser name \n"       
  + "cal\t\tDisplay a monthly calendar \n"
  + "calc\t\tOpen a Scientific Calculator Program \n"
  + "cd\t\tList current directory \n"
  + "close\t\tClose Terminal \n"
  + "clr\t\tClear and reset the screen \n"
  + "date\t\tDisplay date and time \n"
  + "displaytxt\tWill display stored text \n"
  + "deltree\t\tRemove / Delete all subdirectories \n"
  + "echo\t\tWrite arguments back  \n"
  + "halt\t\tHalt system, shut down \n"
  + "logname\t\tDisplay login name  \n"
  + "ls\t\tList directory \n"
  + "mail\t\tOpen a mail-client program \n"
  + "notepad\t\tWill open notepad  \n"
  + "refresh\t\tRefresh system  \n"
  + "reboot\t\tReboot system  \n"
  + "sh\t\tStart a new sub-shell \n"
  + "time\t\tDisplay date and time \n"
  + "webapp\t\tMenu of Web Applications \n"
  + "wc\t\tWord Count \n"
  + "wordpad\t\tWill open wordpad \n"
  + "uname\t\tWill display system name \n"
  + "xpaint\t\tSimple paint program for X \n"
  + "vga\t\tDisplay Screen Resolution \n\n"

  + "Advanced Commands ________________________________________________________\n"
  + "txcolor \"color\"\tWill change the text color to a specific html color. \n"
  + "cgcolor \"color\"\tWill change Terminal color to a specific html color. \n"
  + "fopen \"url\"\t\tWill goto a specific url \"Must include http://\" \n"
  + "ping \"IP\"\t\tWill ping a specific IP or url ex: http://69.147.76.15 \n"
  + "dsktop \"url\"\t\tChange desktop background \"Must include http://\" \n"
  + "srch \"term\"\t\tWill search \"Supreme Search 3000\" for your search term. \n"
  + "cguser \"new_name\"\tChange Username. example: cguser Mike \n"
  + "storetxt \"text\"\tWill store any text you enter. \n"
  + "sbar \"text\"\t\tWill add text to searchbar. \n"
  + "mkdir \"dir\"\t\tMakes a new directory. \n"
  + "rmdir \"/dir\"\t\tRemove / Delete directory. example: rmdir /Photos \n"
  + "[script] \"command\"\tEnter Javascript Commands [script] alert('Hello World')\n"
  + "AI \"question\"\t\tTalk to AI. Smart Terminal uses Artificial Intelligence\n\t\t\tto answer any questions.\n";
	  
  return false;                
} 


//Filesystem
function New_Folder(){
  if (New_File > 1){document.FileSYS.FileInput.value += "\n";}
  document.FileSYS.FileInput.value += document.NewFolder.URL.value;
  document.FileSYS.FileInput.value += document.NewFolder.type.value;
  document.NewFolder.type.selectedIndex = 0;
  document.FileSYS.FileOptions.selectedIndex = 0;
  document.NewFolder.URL.value = "http://";
  Filesystem(); return false;
}

function Filesystem(){

  var i = 0;
  var c = 0;
  var Icon = "";
  var Iconc = 1;
  var LinkName = "";
  var d = 0; var LL = 20; var TT = 10;
  var dirfiles = document.FileSYS.FileInput.value;
  var selected = document.FileSYS.FileOptions.options[document.FileSYS.FileOptions.selectedIndex].value;
  var Vfiles = dirfiles.split("\n");
  var countdirs = Vfiles.length;
  FileSYS.F_Display.value= "C:\\" + User + dir;
  document.getElementById('Search1').style.display = 'none';

  //Display Icon
  for (i = 1; i <= 15; i=i+1){
    IconClass+=i;
    document.getElementById(IconClass).style.display = 'block';
    IconClass = "Icon";
  }

  if (selected == "3"){
    c = 6;
    selected = "1";
    dir = Vfiles[1].replace(/[\s\r\n]+$/, '');
    User =  Vfiles[0].replace(/[\s\r\n]+$/, '');
    DesktopColor = Vfiles[2].replace(/[\s\r\n]+$/, '');
    WindowColor = Vfiles[3].replace(/[\s\r\n]+$/, '');
    Color_Mode = Vfiles[4].replace(/[\s\r\n]+$/, '');
    Random = Vfiles[5].replace(/[\s\r\n]+$/, '');
    FileSYS.F_Display.value= User + dir;
    document.FileSYS.FileInput.value = "";
    for (i = c; i < countdirs; i=i+1){
      document.FileSYS.FileInput.value += Vfiles[i];
    }
    //Set Color
    document.bgColor=DesktopColor;
    Color_Scheme(WindowColor); Show_User(); displaysplash(); Transparency(Color_Mode); document.WallPaper.URL.value = Random;
  }

  if ((selected == "1") && (dirfiles.length >= 8)){
    document.getElementById('DisplayFiles').innerHTML = "";
    document.getElementById('DisplayFiles2').innerHTML = "";

    for (i = c; i < countdirs; i=i+1){
      LinkName = Vfiles[i].substr(11, 15); 
      Icon = Vfiles[i].substr(Vfiles[i].length-4, 4);

      //Select Icon
      if ((Icon.toLowerCase().indexOf("mp3") != -1) || (Icon.toLowerCase().indexOf("wav") != -1)) {
        Icon = "Icons/music.png";
      }
      else if ((Icon.toLowerCase().indexOf("txt") != -1) || (Icon.toLowerCase().indexOf("rtf") != -1)) {
        Icon = "Icons/txt.png";
      }
      else if ((Icon.toLowerCase().indexOf("jpg") != -1) || (Icon.toLowerCase().indexOf("gif") != -1)) {
        Icon = "Icons/Image.png";
      }
      else if ((Icon.toLowerCase().indexOf("avi") != -1) || (Icon.toLowerCase().indexOf("mpg") != -1)) {
        Icon = "Icons/video.png";
      }
      else if (Icon.toLowerCase().indexOf("pdf") != -1){
        Icon = "Icons/pdf.png";
      }
      else if (Icon.toLowerCase().indexOf("exe") != -1){
        Icon = "Icons/exe.png";
      }
      else if (Icon.toLowerCase().indexOf("nxw") != -1){
        Icon = "Icons/nxw.png";
      }
      else if (Icon.toLowerCase().indexOf("zip") != -1){
        Icon = "Icons/zip.png";
      }
      else if ((Icon.toLowerCase().indexOf("htm") != -1) || (Icon.toLowerCase().indexOf("tml") != -1)) {
        Icon = "Icons/Web.png";
      }
      else if (Vfiles[i].toLowerCase().indexOf(" [folder]") != -1){
        Vfiles[i] = Vfiles[i].replace(" [folder]","");
        LinkName = Vfiles[i].substr(11, 15);
        Icon = "Icons/add.png";
      }
      else if (Vfiles[i].toLowerCase().indexOf(" [network]") != -1){
        Vfiles[i] = Vfiles[i].replace(" [network]","");
        LinkName = Vfiles[i].substr(11, 15);
        Icon = "Icons/net.png";
      }
      else if (Vfiles[i].toLowerCase().indexOf(" [drive]") != -1){
        Vfiles[i] = Vfiles[i].replace(" [drive]","");
        LinkName = Vfiles[i].substr(11, 15);
        Icon = "Icons/Hard disk.png";
      }
        else
      {
        Icon = "Icons/webpage.png";
      }

      //Icon from web
      if (Vfiles[i].toLowerCase().indexOf(" [image]") != -1){
        var Input2 = Vfiles[i].split(" [image]");
        Vfiles[i] = Input2[0];
        LinkName = Input2[0].substr(11, 15);
        Icon = Input2[1];
      }

      //Make Clickable Icon
      IconClass+=Iconc;
      if (Icon == "Icons/music.png"){
        Vfiles[i] = Vfiles[i].replace(/\s/g, '%20');
        if (Iconc <= 15){document.getElementById(IconClass).innerHTML = "<a href= Web-App/Media%20Player.php?User_Input=" + Vfiles[i] + " title=\"" + Vfiles[i] + "\" onmouseover=\"this.style.backgroundColor='white'\" onmouseout=\"this.style.backgroundColor='transparent'\" onclick=\"window.open(this.href, '','height=240,width=750, scrollbars=yes, resizable=yes');return false;\"><img src=\"" + Icon + "\" width=\"48\" height=\"48\" BORDER=0>" + LinkName + "</a>&nbsp;"}
        document.getElementById('DisplayFiles2').innerHTML += "<DIV STYLE='position:absolute;left:"+LL+";top:"+TT+"'><a href= Web-App/Media%20Player.php?User_Input=" + Vfiles[i] + " title=\"" + Vfiles[i] + "\"  onclick=\"window.open(this.href, '','height=240,width=750, scrollbars=yes, resizable=yes');return false;\"><img src=\"" + Icon + "\" width=\"48\" height=\"48\" BORDER=0>" + LinkName + "</a>&nbsp;</DIV>"
     }
      else if (Icon == "Icons/nxw.png"){
        if (Iconc <= 15){document.getElementById(IconClass).innerHTML = "<a href=\"javascript:Writer_Open("+WRT+")\" title=\"" + Vfiles[i] + "\" onmouseover=\"this.style.backgroundColor='white'\" onmouseout=\"this.style.backgroundColor='transparent'\"><img src=\"" + Icon + "\" width=\"48\" height=\"48\" BORDER=0>" + LinkName + "</a>&nbsp;"}
        document.getElementById('DisplayFiles2').innerHTML += "<DIV STYLE='position:absolute;left:"+LL+";top:"+TT+"'><a href=\"javascript:Writer_Open("+WRT+")\" title=\"" + Vfiles[i] + "\"><img src=\"" + Icon + "\" width=\"48\" height=\"48\" BORDER=0>" + LinkName + "</a>&nbsp;</DIV>"
        WRT++;
     }
        else
      {
        if (Iconc <= 15){document.getElementById(IconClass).innerHTML = "<a href=\"" +Vfiles[i]+ "\" title=\"" + Vfiles[i] + "\" onmouseover=\"this.style.backgroundColor='white'\" onmouseout=\"this.style.backgroundColor='transparent'\" onclick=\"window.open(this.href, '','height=500,width=500, scrollbars=yes, resizable=yes, location=yes');return false;\"><img src=\"" + Icon + "\" width=\"48\" height=\"48\" BORDER=0>" + LinkName + "</a>&nbsp;"}
        document.getElementById('DisplayFiles2').innerHTML += "<DIV STYLE='position:absolute;left:"+LL+";top:"+TT+"'><a href=\"" +Vfiles[i]+ "\" title=\"" + Vfiles[i] + "\" onclick=\"window.open(this.href, '','height=500,width=500, scrollbars=yes, resizable=yes, location=yes');return false;\"><img src=\"" + Icon + "\" width=\"48\" height=\"48\" BORDER=0>" + LinkName + "</a>&nbsp;</DIV>"
      }

      d++; if (d <= 3){LL = LL + 160;}
      else{d = 0; LL = 20; TT = TT + 80;}

      IconClass = "Icon";
      New_File++;
      Iconc++;

    }

  }

  if (selected == "2"){
    var w = window.open();
    w.document.writeln("<xmp>" + User);
    w.document.writeln(dir);
    w.document.writeln(DesktopColor);
    w.document.writeln(WindowColor);
    w.document.writeln(Color_Mode);
    w.document.writeln(Random);
    w.document.writeln(dirfiles + "</xmp>");
  }

  if (selected == "4"){
    document.getElementById('DisplayFiles2').innerHTML = "<h1>Help Menu</h1><big>"
    + "To add files to your \"Virtual File System\" add your favorite urls in the textbox "
    + "below. You can add any type of url links including html, mp3, wav, pdf, txt, jpg, gif and more. "
    + "Also, remember to include \"http://\" in your links, and add one url per line. "
    + "You can add as many urls as you like.</big>"
    + "<br><br><h1>Optional</h1><big>"
    + "To edit your \"Username\" and \"Directory\", open Mini Terminal to make changes."
    + "Virtual File System keeps memory of all links added even after it has been closed.</big>"
    + "<br><br><h1>Import Backup</h1><big>"
    + "After you have made a \"Backup Copy\" of your virtual files, simply copy and paste the backup text in the textbox below to retrieve your data.</big>"
    + "<br><br><h1>Optional Change Icon</h1><big>"
    + "Use the following example below to change icons: <br>"
    + "Folder Icon: http://www.example.com [folder] <br>"
    + "Network Icon: http://www.example.com [network] <br>"
    + "Image as Icon: http://www.example.com [image]image_url</big>";
  }

}


//Desktop 2
function Desktop2(){
  if (Desktop == 1){
    Desktop = 2; Hide_Icons();
    document.getElementById('Search1').style.display = 'none';
    document.getElementById('DisplayFiles').innerHTML = "<iframe src='Desktop 2.htm?var1="+User+ "&var2=" + "www." + dir + "&var3=" + uname + "&var4=" + DesktopColor + "&var5=" + Random + "&var6=" + WindowColor + "' width=" + screen.width + " height=" + screen.height + " frameborder='0'>"
    + "</frame>";
  }
    else{Show_Icons();}
}
function Hide_Icons(){
  for (i = 1; i <= 15; i=i+1){
    IconClass+=i;
    document.getElementById(IconClass).style.display = 'none';
    IconClass = "Icon";
  }
}
function Show_Icons(){
  Desktop = 1;
  for (i = 1; i <= 15; i=i+1){
    IconClass+=i;
    document.getElementById(IconClass).style.display = 'block';
    IconClass = "Icon";
  }document.getElementById('DisplayFiles').innerHTML = "";
}



//Keep Main Window
function Keep_Window(){Win_Select = 1}

//New Window
var Restore=0;
var Drag=false;
var Win_Select = 1;
var iwidth,iheight = 0;

function loadwindow(url,width,height){

//Store Recent Program
Rurl = url; Rwidth = width; Rheight = height;

//Window Select
if (Win_Select == 1){
document.getElementById("Main_Window").style.display=''
document.getElementById("Main_Window").style.width=iwidth=width+"px"
document.getElementById("Main_Window").style.height=iheight=height+"px"
document.getElementById("Main_Window").style.left=document.getElementById&&!document.all? window.pageXOffset+"px" : document.body.scrollLeft+"px"
document.getElementById("Main_Window").style.top=document.getElementById&&!document.all? window.pageYOffset+"px" : document.body.scrollTop+"px"
document.getElementById("Main_Frame").src=url}
if (Win_Select == 2){
document.getElementById("Extra_Window").style.display=''
document.getElementById("Extra_Window").style.width=iwidth=width+"px"
document.getElementById("Extra_Window").style.height=iheight=height+"px"
document.getElementById("Extra_Window").style.left=document.getElementById&&!document.all? window.pageXOffset+"px" : document.body.scrollLeft+"px"
document.getElementById("Extra_Window").style.top=document.getElementById&&!document.all? window.pageYOffset+"px" : document.body.scrollTop+"px"
document.getElementById("Extra_Frame").src=url;}
else if (Win_Select == 3){
document.getElementById("Extra_Window2").style.display=''
document.getElementById("Extra_Window2").style.width=iwidth=width+"px"
document.getElementById("Extra_Window2").style.height=iheight=height+"px"
document.getElementById("Extra_Window2").style.left=document.getElementById&&!document.all? window.pageXOffset+"px" : document.body.scrollLeft+"px"
document.getElementById("Extra_Window2").style.top=document.getElementById&&!document.all? window.pageYOffset+"px" : document.body.scrollTop+"px"
document.getElementById("Extra_Frame2").src=url;}
else if (Win_Select == 4){
document.getElementById("Extra_Window3").style.display=''
document.getElementById("Extra_Window3").style.width=iwidth=width+"px"
document.getElementById("Extra_Window3").style.height=iheight=height+"px"
document.getElementById("Extra_Window3").style.left=document.getElementById&&!document.all? window.pageXOffset+"px" : document.body.scrollLeft+"px"
document.getElementById("Extra_Window3").style.top=document.getElementById&&!document.all? window.pageYOffset+"px" : document.body.scrollTop+"px"
document.getElementById("Extra_Frame3").src=url;}
else if (Win_Select == 5){
document.getElementById("Extra_Window4").style.display=''
document.getElementById("Extra_Window4").style.width=iwidth=width+"px"
document.getElementById("Extra_Window4").style.height=iheight=height+"px"
document.getElementById("Extra_Window4").style.left=document.getElementById&&!document.all? window.pageXOffset+"px" : document.body.scrollLeft+"px"
document.getElementById("Extra_Window4").style.top=document.getElementById&&!document.all? window.pageYOffset+"px" : document.body.scrollTop+"px"
document.getElementById("Extra_Frame4").src=url; Win_Select = 0;}
Win_Select++;
}

function maximize(){
if (Restore==0){
Restore=1 //maximize window
document.getElementById("maxname").setAttribute("src","Desktop 2/restore.gif")
document.getElementById("Main_Window").style.width=document.getElementById&&!document.all? window.innerWidth-10+"px" : document.body.clientWidth+"px"
document.getElementById("Main_Window").style.height=document.getElementById&&!document.all? window.innerHeight-60+"px" : document.body.clientHeight-50+"px"
document.getElementById("Main_Window").style.left=document.getElementById&&!document.all? window.pageXOffset+"px" : document.body.scrollLeft+"px"
document.getElementById("Main_Window").style.top=document.getElementById&&!document.all? window.pageYOffset+"px" : document.body.scrollTop+"px"
}
else
{
Restore=0 //restore window
document.getElementById("maxname").setAttribute("src","Desktop 2/max.gif")
document.getElementById("Main_Window").style.width=iwidth
document.getElementById("Main_Window").style.height=iheight
document.getElementById("Main_Window").style.left=document.getElementById&&!document.all? window.pageXOffset+"px" : document.body.scrollLeft+"px"
document.getElementById("Main_Window").style.top=document.getElementById&&!document.all? window.pageYOffset+"px" : document.body.scrollTop+"px"
}
}

function drag_drop(e){
if (document.all&&document.getElementById&&Drag&&event.button==1){
document.getElementById("Main_Window").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("Main_Window").style.top=tempy+event.clientY-offsety+"px"
}
else if (document.getElementById&&!document.all&&Drag){
document.getElementById("Main_Window").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("Main_Window").style.top=tempy+e.clientY-offsety+"px"
}
}

function initialize(e){
offsetx=document.all&&document.getElementById? event.clientX : e.clientX
offsety=document.all&&document.getElementById? event.clientY : e.clientY
document.getElementById("Content").style.display="none" //extra
tempx=parseInt(document.getElementById("Main_Window").style.left)
tempy=parseInt(document.getElementById("Main_Window").style.top)

Drag=true
document.getElementById("Main_Window").onmousemove=drag_drop
}

function Close_Window(){
document.getElementById("Main_Window").style.display="none"
document.getElementById("Main_Frame").src="Web-App/Loading.htm";
}

function stop(){
Drag=false;
document.getElementById("Content").style.display="block"
}

//Screen Resolution
function Screen_Res(VGA){document.body.style.zoom = screen.width/VGA;}


//Writer App
var FLName = new Array();
var FContent = new Array();
var WRT = 0; var WRT2 = 0; var WRT_Cached = 0;
function SWriter(){
  WRT = 0;
  FLName[WRT2] = document.WTP.FLName.value;
  FContent[WRT2] = document.WTP.DI.value; 
    if (FLName[WRT2].length >= 8){ 
      alert(FLName[WRT2]+'.nxw Saved Successfully');
      NewFolder.URL.value = "           "+FLName[WRT2]+".nxw"; WRT2++; New_Folder();
    }else{
      alert('FileName must be 8 characters or higher.');
    }
}
function Writer_Open(WRT3){
  document.getElementById("Writer2").style.display = 'block';
  WRT_Cached = WRT3; WTP.FLName.value = FLName[WRT3]; WTP.DI.value = FContent[WRT3];
}
function SWriter2(){
  FLName[WRT_Cached] = document.WTP.FLName.value;
  FContent[WRT_Cached] = document.WTP.DI.value;
  alert(FLName[WRT_Cached]+'.nxw Update Successfully');
}
function PreHTML(){
  var w = window.open();
  w.document.writeln("<TITLE>"+document.WTP.FLName.value+"</TITLE>");
  w.document.writeln(document.WTP.DI.value);
  w.document.close();
  return false;
}


//Taskbar_Change
function Taskbar_Change(color){
  for (i = 0; i <= 1; i++){if (document.DeskColor.R1[i].checked == true){var sel = document.DeskColor.R1[i].value; }}
  if (sel == 1){document.bgColor= color; var DesktopColor = color}
  if (sel == 2){ WindowColor = color; Color_Scheme(color);}
}
function Color_Scheme(color){
    document.getElementById("TaskBar").style.backgroundColor = color;
    document.getElementById("Adjust").style.backgroundColor = color;
    document.getElementById("Restore1").style.backgroundColor = color;
    document.getElementById("Restore2").style.backgroundColor = color;
    document.getElementById("Restore3").style.backgroundColor = color;
    document.getElementById("Restore4").style.backgroundColor = color;
    document.getElementById("Restore5").style.backgroundColor = color;
    document.getElementById("start").style.backgroundColor = color;
    document.getElementById("start").style.borderColor = color;
    document.getElementById("start2").style.borderColor = color;
    document.getElementById("SUB").style.borderColor = color;
    document.getElementById("Dock_Menu").style.borderColor = color;
    document.getElementById("MyComputer2").style.backgroundColor = color;
    document.getElementById("Background2").style.backgroundColor = color;
    document.getElementById("Menu_Items").style.backgroundColor = color;
    document.getElementById("Menu_Items2").style.backgroundColor = color;
    document.getElementById("Main_Window1").style.backgroundColor = color;
    document.getElementById("Main_Frame").style.borderColor = color;
    document.getElementById("Extra_Window1").style.backgroundColor = color;
    document.getElementById("Extra_Frame").style.borderColor = color;
    document.getElementById("Extra_Window22").style.backgroundColor = color;
    document.getElementById("Extra_Frame2").style.borderColor = color;
    document.getElementById("Extra_Window33").style.backgroundColor = color;
    document.getElementById("Extra_Frame3").style.borderColor = color;
    document.getElementById("Extra_Window44").style.backgroundColor = color;
    document.getElementById("Extra_Frame4").style.borderColor = color;
    document.getElementById("Explorer2").style.backgroundColor = color;
    document.getElementById("Explorer3").style.borderColor = color;
    document.getElementById("web4").style.borderColor = color;
    document.getElementById("more_web4").style.borderColor = color;
    document.getElementById("Screen").style.backgroundColor = color;
    document.getElementById("furl").style.backgroundColor = color;
    document.getElementById("home").style.backgroundColor = color;
    document.getElementById("res").style.backgroundColor = color;
    document.getElementById("gam").style.backgroundColor = color;
    document.getElementById("news").style.backgroundColor = color;
    document.getElementById("web5").style.backgroundColor = color;
    document.getElementById("MyComputer").style.borderColor = color;
    document.getElementById("Background").style.borderColor = color;
    document.getElementById("Control").style.borderColor = color;
    document.getElementById("Writer22").style.backgroundColor = color;
    document.getElementById("Writer23").style.borderColor = color;
    document.getElementById("Filesystem").style.borderColor = color;
    document.getElementById("Filesystem2").style.backgroundColor = color;
    document.getElementById("FileMenu").style.backgroundColor = color;
}

function Transparency(Clear){
  TaskBar.style.opacity = Clear/10;
  TaskBar.style.filter  = "alpha(opacity=" + Clear + ")"; Color_Mode = Clear;
}

//Memory Usage
function RAM(){
  var To_KB = (document.body.innerHTML.length)/1024;
  var memory_usage = To_KB.toFixed(0);
  document.getElementById("RAM").value = memory_usage + " KB";
}

//Recent_Program
function Recent_Program(){
  if (Rurl == "NA"){alert('No Recent Programs Stored');}
    else{loadwindow(Rurl,Rwidth,Rheight);}
}

//File Explorer
function Explorer(){document.getElementById('Explorer3').innerHTML = document.getElementById('DisplayFiles2').innerHTML;}

//Update
var splashmessage=new Array();
splashmessage[0]="Updating ..."; 
splashmessage[1]="Saving Your Settings ..."; var splashc=0; 
function displaysplash(){ 
  if (splashc<2){document.getElementById('splashcontainer').style.display='block';
    splashcontainer.innerHTML='<b><font face="Arial" size="4">'+splashmessage[splashc]+'</font></b>'; splashc++;
    setTimeout("displaysplash()",1000);}else{splashc=0; document.getElementById('splashcontainer').style.display='none';
  } 
}

//Move Icons's
function ILeft(event){var the_style = document.getElementById(event).style; var Move_Div = parseInt(the_style.left) - 160; the_style.left = Move_Div;}
function IRight(event){var the_style = document.getElementById(event).style; var Move_Div = parseInt(the_style.left) + 160; the_style.left = Move_Div;}
function IDown(event){var the_style = document.getElementById(event).style; var Move_Div = parseInt(the_style.top) + 80; the_style.top = Move_Div;}
function IUp(event){var the_style = document.getElementById(event).style; var Move_Div = parseInt(the_style.top) - 80; the_style.top = Move_Div;}

//Clearbar
Transparency(65);
