/**********************************************************************************
 *** IST163: Web programming
 *** Data structures and functions for keeping track of content
 **********************************************************************************/
 
 var Content = new Array(
 	 {	
	 	title	: "HyperText Markup Language",
    	href	: null	
    },
    { 
	  title   : "Introduction to the environment",
	  href    : "html01.html",
	  section : ["Transferring files to IST server", "Creating/editing files on the server", "Submitting the assignments"]
    },
    { 
	  title   : "Introduction to HTML",
	  href    : "html02.html",
	  section : [ "Structure of HTML document", "Formatting text", "Manipulating fonts", "Comments in HTML" ]
    },
    {
    	title	: "Links, Images, and Lists in HTML documents",
    	href	: "html03.html",
	section : ["Links", "Images", "Unordered lists", "Ordered lists"]	
    },
    {
    	title	: "Tables in HTML documents",
    	href	: "html04.html",
		section : ["Simple tables", "Optional parameters of the tag <kbd>table</kbd>",
		           "Playing with cells and data inside cells", "Combining cells together",
				   "Table header", "Nested tables", "Using tables to format pages"]	
    },
    {
    	title	: "User's input in HTML",
    	href	: "html05.html",
		section : ["Forms", "Tag <kbd>&lt;input></kbd>", "Tag <kbd>&lt;select></kbd>",
		   "Tag <kbd>&lt;textarea></kbd>", "Tag <kbd>&lt;button></kbd>"]	
    },
    {
    	title	: "Sounds on HTML page and other things",
    	href	: "html06.html",
		section : ["Tag <kbd>&lt;bgsound></kbd>", "Tag <kbd>&lt;embed></kbd>", 
		           "Tags <kbd>&lt;div></kbd> and <kbd>&lt;span></kbd>"]	
    },
    // ------------------------------------------------------------------------------
    {	
    	title	: "Cascading Style Sheets",
    	href	: null	
    },
    {
    	title	: "Cascading Style Sheets. Introduction",
    	href	: "css07.html",
		section : ["How to apply styles to object in web documents", "Selectors or target objects for the rules",
		           "Font Properties"]	
    },
    {
    	title	: "Text, Color, and Background properties.",
    	href	: "css08.html",
	section : ["How to manipulate background and color using CSS", "Text Properties"]	
    },
    {
    	title	: "Box properties of HTML elements.",
    	href	: "css09.html",
		section : ["Border properties", "Width and height", "Margin properties", "Padding properties"]	
    },
    {
    	title	: "Visual effects and list elements in CSS.",
    	href	: "css10.html",
		section : ["Visual effects", "Positioning scheme", "List elements"]	
    },
    {
    	title	: "Filters. [<span style='font-size:90%; font-style:italic;'>optional</span>]",
    	href	: "css11.html",
		section : ["Static visual filters", "Transition filters", "CSS Filter references"]	
    },
    {
    	title	: "Pseudo-classes and pseudo-elements. Using external styles.",
    	href	: "css12.html",
		section : ["Link related pseudo-classes", "Some other pseudo-classes", "Pseudo-elements", 
		           "How to use styles in HTML documents"]	
    },
    // ------------------------------------------------------------------------------
    {	
    	title	: "JavaScript",
    	href	: null	
    },
    {
    	title	: "Introduction to JavaScript.",
    	href	: "js13.html",
	section : ["Comments in JavaScript", "Variables in JavaScript", "Using Strings", "Using Arrays", "Objects",
	           "Manipulation with variables. Operators"]	
    },
    {
    	title	: "Controlling program flow.",
    	href	: "js14.html",
	section : ["Conditional Statements", "Conditional Operator <kbd><b>?</b></kbd>", "Loops", 
	           "The <kbd>switch</kbd> statement", "Functions", "JavaScript statement reference"]	
    },
    {
    	title	: "DOM. Accessing page elements.",
    	href	: "js15.html",
	section : ["Browser predefined objects. Data Object Model", "<kbd>Location</kbd> object" , 
	           "<kbd>History</kbd> object", "<kbd>document</kbd> object", "<kbd>Form</kbd> object",
	           "Accessing elements by ID", "DOM references"]	
    },
    {
    	title	: "Events, event handlers, and event object.",
    	href	: "js16.html",
	section : ["Events", "Event handlers", "<kbd>Event</kbd> object", "JavaScript event references"]	
    },
    {
    	title	: "Putting things together. Dynamic web pages.",
    	href	: "js17.html",
	section : ["Simple menu", "Simple form validation", "Popup hint", "Controlling buttons. Small joke"]	
    },
    {
    	title	: "<kbd>Date</kbd> object. Timer events.",
    	href	: "js18.html",
	section : ["<kbd>Date</kbd> object", "Setting timer events and their handlers",
	           "Clearing timer event. Removing handlers", "Examples"]	
    },
    {
    	title	: "Object <kbd>Window</kbd>. Manipulating browser windows from JavaScript.",
    	href	: "js19.html",
	section : ["Creating new windows", "Manipulating windows", 
                   "Controlling windows", "Creating window content on-fly"]	
    },
    {
    	title	: "More about Arrays and Strings. <span style='font-size:90%; font-style:italic;'>[optional]</span>",
    	href	: "js20.html",
	section : ["<kbd>Array</kbd> object", "<kbd>String</kbd> object"]	
    },
    {
    	title	: "Regular Expressions in JavaScript.",
    	href	: "js21.html",
	section : ["Regular expression", "Properties of <kbd>RegExp</kbd> object", "Using regular expressions", 
	           "Getting information about a match", "String replacement", 
	           "Some other properties of <kbd>RegExp</kbd> object", "Data-entry validation"]	
    },
    // ------------------------------------------------------------------------------
    {	
    	title	: "PHP",
    	href	: null	
    },
    {
    	title	: "Server side scripting. Introduction in PHP.",
    	href	: "php22.html",
	section : ["PHP scripts", "Comments in PHP language", "Variables in PHP scripts", 
	           "Passing arguments to PHP scripts", "Date and time functions"]	
    },
    {
    	title	: "Apache and PHP for Windows platforms. Installation and simple configuration.  <span style='font-size:90%; font-style:italic;'>[optional]</span>",
    	href	: "php23.html",
	section : ["Apache installation", "PHP installation", "PHP Integrated Development Environment", 
	           "Apache settings and some security"]	
    },
    {
    	title	: "Flow control constructions in PHP.",
    	href	: "php24.html",
        section : ["<kbd><b>if</b></kbd> statements", "Boolean expressions", 
                   "<kbd><b>switch</b></kbd> statement", "Question mark operator", 
                   "<kbd><b>while</b></kbd> loop", "<kbd><b>do-while</b></kbd> loop", 
                   "<kbd><b>for</b></kbd> loop", "<kbd><b>foreach</b></kbd> loop"]	
    },
    {
    	title	: "Arrays in PHP.",
    	href	: "php25.html",
        section : ["Initialization of an array", "<kbd><b>array()</b></kbd> constructor", 
                   "String indexed arrays", "Moving along an array", 
                   "Iterating through non-sequential array. Functions <kbd>each()</kbd> and <kbd>list()</kbd>", 
                   "Strings and arrays in PHP", "Some other array functions <i>[optional]</i>"]	
    },
    {
    	title	: "Working with files on the server.",
    	href	: "php26.html",
        section : ["Opening files", "Closing files", "Displaying files", "Reading from files", 
		   "Writing to files", "Navigating within files", "Working with directories"]	
    },
    {
    	title	: "Organizing your code. Functions.",
    	href	: "php27.html",
        section : ["Defining and calling functions", "Passing arguments to a function", 
                   "Scope of variables", "Splitting code into different files"]	
    },
    {
    	title	: "Regular expressions functions in  PHP.",
    	href	: "php28.html",
        section : ["Native PHP regular expressions", "Perl-style regular expressions in PHP", 
                   "Some string functions <i>[optional]</i>"]	
    },
    {
    	title	: "Error handling.",
    	href	: "php29.html",
        section : ["Error types", "PHP error messages", "Setting the error reporting level", 
                   "Error handling", "Logging errors"]	
    },
    // ------------------------------------------------------------------------------
    {
	    title   : "Visual tools",
	    href    : null
    },
	{
	    title   : "Text formatting tags editor",
	    href    : "veditor.html"
    },
	{
	    title   : "RGB color selector",
	    href    : "' onClick='window.open(\"color_selector.html\", null, \"height=380px; width=720px; status=no;\"); return false;"
    },
	{
	    title   : "CSS Master",
	    href    : "cssmaster.html"
    },
	{
	    title   : "Openning new windows",
	    href    : "examples/js_winex.html"
    },
	{
	    title   : "JavaScript regular expression tester",
	    href    : "examples/js_reg.html"
    },
	{
	    title   : "Native PHP regular expression playground",
	    href    : "php_examples/php_regexp.html"
    },
	{
	    title   : "Perl-style PHP regular expression playground",
	    href    : "php_examples/php_perlreg.html"
    },
    {
	    title   : "Appendix",
	    href    : null
    },
    {
	    title   : "HTML examples",
	    href    : "examples/index.html",
	    section : null
    },
    {
	    title   : "PHP examples",
	    href    : "php_examples/index.html",
		section : null
    }
 );
 
 
 function int_to_str(i)
 {
    var res = "";
    if( i < 10 ) res = "0";
	res += i.toString();
	return res; 
 }
 
  
  // shows/hides the content of the chapter clicked on
 function show_hide(ind)
 {
    var open_page = true;
    if( ind > 99 ){
       ind %= 100;
       open_page = false;
    }
    var sid = "sec"+ind;
    var fid = "fldr"+ind;
    if( document.all[sid] ){
       if( document.all[sid].style.display == "none" ){
          document.all[fid].src = "pics/fldropen.bmp";
          document.all[sid].style.display = "";
       }
       else{
          if( open_page ) return true;
          document.all[fid].src = "pics/fldrshut.bmp";
          document.all[sid].style.display = "none";
       }
       return false;
    }
    return true;
 }
 
 function print_content_table()
 {
    var type = 'I';
	var counter = 0;
	var part = 0;
    if( Content && Content.length ){
       document.writeln("<ol type=I>");
       for(i=0;i<Content.length;i++){
          if( Content[i].href ){
		    counter++;
            if( type=='I' ){
              type = '1';
			  if( part < 5 )
                document.writeln(' <ol type=1 start='+counter+'>');
			  else
	            document.writeln("<ul>");
            }
            if( Content[i].section ){
	        document.writeln('<li><img align=absbottom src="pics/fldrshut.bmp" style="filter:chroma(color=white); margin-left:-5px; margin-right:0px;" id=fldr'+i+' onClick="return show_hide('+(i+100)+');">');
	        document.writeln("<a href='"+Content[i].href+"' onClick='return show_hide("+i+");'>"+Content[i].title+"</a>");
	    }
	    else{
	        document.writeln("<li><a href='"+Content[i].href+"'>"+Content[i].title+"</a>");

	    }
	        if( Content[i].section && Content[i].section.length ){
	          document.writeln("<ol type=1 id=sec"+i+" style='display:none'>");
	          for(j=0;j<Content[i].section.length;j++){
		        if( Content[i].section[j].href ){
		          document.writeln("<li type=A> <a href='"+Content[i].section[j].href+
				   "'>"+Content[i].section[j].title+"</a>");
		        }
		        else{
		           document.writeln("<li> <a href='"+Content[i].href+"#l"+int_to_str(counter)+int_to_str(j+1)+
				   "'>"+Content[i].section[j]+"</a>");
		        }
	          }
	          document.writeln("</ol>");
	        }
          }
          else{ // this is a Separator
		    part++;
            if( type != 'I' ){
			  if( part <=5  )
                document.writeln('</ol>');
			  else
                document.writeln('</ul>');
              type = 'I';
            }
            document.writeln('<li> <span style="font-weight:bolder; font-size:120%;">'+Content[i].title+'</span>');
          }
       }
       document.writeln("</ol>");
    }
 }

 
 // ==============================================================================

