/*
 * edocx, Copyright (c) 2009, Jeremy G.W. Aiyadurai, All Rights Reserved.
 */



/*
function CreateAPIDoc(data)
{
	mchunks = data.split('!-');	
	var stringToReturn = "<table>";	
	for(var i=0;i<data.length;i++)
	{
		if((data[i].endsWith("HeadEnd-") == true) || (data[i].endsWith("NoteEnd-") == true))
		{
			part = ""+data[i];
			part = part.replace("HeadEnd-",'');
			part = part.replace("NoteEnd-",'');			
			rowstart = "<tr><td id='headernote'>";
			rowend = "</td></tr>";			
			p = part.split('\n');			
			createp = rowstart;			
			for(var k=0;k<p.length;k++)
			{
				createp += p[k]+"<br>";
			}
			createp += rowend;
			stringToReturn += createp;	
		}
		if(data[i].endsWith("BodyEnd-") == true)
		{
			part = ""+data[i];
			part = part.replace("BodyEnd-",'');
			
			p = part.split('^');
			
			for(var m=0;m<p.length;m++)
			{
				lines = p[m].split('\n');
				
				head = "<tr><td colspan='2'>"+lines[0]+"</td></tr>";
				
				args = "";
				defs = "";
				
				for(var l=1;l<lines.length;l++)
				{
							if(lines[l].indexOf("-*"))
							{
								args += lines[l].replace("-*",'')+"|";
							}
							else
							{
								defs += lines[l].replace("- ",'')+"|";
							}							
				}
				
			}			
			
		}
		
	}
	stringToReturn += "</table>"
	return stringToReturn;
}
*/


function WindowWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    }
  return myWidth;
}


function LoadContentAPIDoc(doc,pageid,tag,T)
{
            
              		p = pageid.split('/');              
              		n = p[p.length-1];
              		n = n.replace(".txt",'');
              		fn = n.split('_');
              		n = fn[1];
					
					//data = CreateAPIDoc(xhr.responseText);
					              
              		document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-200)+";\"><table style=\"position:relative;width:"+ (WindowWidth()-260) +";height:5%;\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td></tr></table><iframe src=\"http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?api="+pageid+"&DOC="+doc+"&T=Win32\" style=\"border: none;\" height=\"94%\" width=\"100%\" valign=\"top\"></iframe></body>";
   
}




function LoadContentTextArea(page,tag,T)
{
 /*
 if(T == true)
              {
    document.getElementById(""+tag).innerHTML = "<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><center><table><tr><td>Loading</td></tr></table></center></body>";
		}
 */   
    var xhr;
if (window.XMLHttpRequest)  {
    xhr = new XMLHttpRequest();
}
else
 if (window.ActiveXObject)
 {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer
 }
    xhr.onreadystatechange  = function()
    {
         if(xhr.readyState  == 4)
         {

              if(T == true)
              {
              	if(xhr.status  == 200)
              	{              
              		p = page.split('/');              
              		n = p[p.length-1];
              		n = n.replace(".txt",'');
              		fn = n.split('_');
              		n = fn[1];              
              		document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><table width=\""+ (WindowWidth()-260)+"\" height=\"5%\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td></tr></table><textarea readonly name=\"userInput\" style=\"border: none;background-color:#F4F7F7;color:#0000ff;position:relative;width:"+ (WindowWidth()-260) +";height:95%;overflow-y: scroll;\">"  + xhr.responseText +"</textarea></body>";
              	}
              	else
              	{
              		document.getElementById(""+tag).innerHTML ="Error code " + xhr.status;
         	  	}
         	  }

         }
    };
   xhr.open("GET", ""+page,  true);
   xhr.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
   xhr.send(null);
}





function LoadContentCodeBox(doc,page,tag,CT,T)
{
 /*
 if(T == true)
              {
    document.getElementById(""+tag).innerHTML = "<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><center><table><tr><td>Loading</td></tr></table></center></body>";
		}
 */   
    var xhr;
if (window.XMLHttpRequest)  {
    xhr = new XMLHttpRequest();
}
else
 if (window.ActiveXObject)
 {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer
 }
    xhr.onreadystatechange  = function()
    {
         if(xhr.readyState  == 4)
         {

              if(T == true)
              {
              	if(xhr.status  == 200)
              	{              
              		p = page.split('/');              
              		n = p[p.length-1];
              		n = n.replace(".txt",'');
              		fn = n.split('_');
              		n = fn[1];              //style=\"position:relative;width:"+ (WindowWidth()-260) +";height:95%;overflow-y: scroll;\"
              		//document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><table width=\""+ (WindowWidth()-260)+"\" height=\"5%\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td></tr></table><pre  name=\"code\" class=\""+CT+"\" >"  + xhr.responseText +"</pre></body>";
              		
              		//http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?code="+page+"&syn="+CT+"&DOC="+doc+"
              		document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-200)+";\"><table style=\"position:relative;width:"+ (WindowWidth()-260) +";height:5%;\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td></tr></table><iframe src=\"http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?code="+page+"&syn="+CT+"&DOC="+doc+"\" style=\"border: none;\" height=\"94%\" width=\"100%\" valign=\"top\"></iframe></body>";
              		
              		//document.getElementById(""+tag).innerHTML ="Error code " + page;
              	
              	}
              	else
              	{
              		document.getElementById(""+tag).innerHTML ="Error code " + xhr.status;
         	  	}
         	  }

         }
    };
   xhr.open("GET", ""+page,  true);
   xhr.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
   xhr.send(null);
}



function LoadContentDescBox(doc,page,tag,T)
{
 /*
 if(T == true)
              {
    document.getElementById(""+tag).innerHTML = "<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><center><table><tr><td>Loading</td></tr></table></center></body>";
		}
 */   
    var xhr;
if (window.XMLHttpRequest)  {
    xhr = new XMLHttpRequest();
}
else
 if (window.ActiveXObject)
 {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer
 }
    xhr.onreadystatechange  = function()
    {
         if(xhr.readyState  == 4)
         {

              if(T == true)
              {
              	if(xhr.status  == 200)
              	{              
              		p = page.split('/');              
              		n = p[p.length-1];
              		n = n.replace(".txt",'');
              		fn = n.split('_');
              		n = fn[1];              //style=\"position:relative;width:"+ (WindowWidth()-260) +";height:95%;overflow-y: scroll;\"
              		//document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><table width=\""+ (WindowWidth()-260)+"\" height=\"5%\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td></tr></table><pre  name=\"code\" class=\""+CT+"\" >"  + xhr.responseText +"</pre></body>";
              		
              		//http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?code="+page+"&syn="+CT+"&DOC="+doc+"
              		document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-200)+";\"><table style=\"position:relative;width:"+ (WindowWidth()-260) +";height:5%;\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td></tr></table><iframe src=\"http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?desc="+page+"&DOC="+doc+"\" style=\"border: none;\" height=\"94%\" width=\"100%\" valign=\"top\"></iframe></body>";
              		
              		//document.getElementById(""+tag).innerHTML ="Error code " + page;
              	
              	}
              	else
              	{
              		document.getElementById(""+tag).innerHTML ="Error code " + xhr.status;
         	  	}
         	  }

         }
    };
   xhr.open("GET", ""+page,  true);
   xhr.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
   xhr.send(null);
}


function LoadContentCpyDiscBox(doc,page,tag,T)
{
 /*
 if(T == true)
              {
    document.getElementById(""+tag).innerHTML = "<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><center><table><tr><td>Loading</td></tr></table></center></body>";
		}
 */   
    var xhr;
if (window.XMLHttpRequest)  {
    xhr = new XMLHttpRequest();
}
else
 if (window.ActiveXObject)
 {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer
 }
    xhr.onreadystatechange  = function()
    {
         if(xhr.readyState  == 4)
         {

              if(T == true)
              {
              	if(xhr.status  == 200)
              	{              
              		p = page.split('/');              
              		n = p[p.length-1];
              		n = n.replace(".txt",'');
              		fn = n.split('_');
              		n = fn[1];              //style=\"position:relative;width:"+ (WindowWidth()-260) +";height:95%;overflow-y: scroll;\"
              		//document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><table width=\""+ (WindowWidth()-260)+"\" height=\"5%\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td></tr></table><pre  name=\"code\" class=\""+CT+"\" >"  + xhr.responseText +"</pre></body>";
              		
              		//http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?code="+page+"&syn="+CT+"&DOC="+doc+"
              		document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-200)+";\"><table style=\"position:relative;width:"+ (WindowWidth()-260) +";height:5%;\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td><td align=\"right\" style=\"font-family:Sans-serif;\"><a href=\"http://www.system-engine.com/contact.php?ref=doc&url=http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?copydisc="+page+"|DOC="+doc+"\" target=\"frame\" style=\"font-family:Sans-serif;font-size:10pt;\">Notify/Contact Admin</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table><iframe name=\"frame\" src=\"http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?copydisc="+page+"&DOC="+doc+"\" style=\"border: none;\" height=\"94%\" width=\"100%\" valign=\"top\"></iframe></body>";
              		
              		//document.getElementById(""+tag).innerHTML ="Error code " + page;
              	
              	}
              	else
              	{
              		document.getElementById(""+tag).innerHTML ="Error code " + xhr.status;
         	  	}
         	  }

         }
    };
   xhr.open("GET", ""+page,  true);
   xhr.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
   xhr.send(null);
}


function LoadContactForm(doc,page,tag,T)
{
 /*
 if(T == true)
              {
    document.getElementById(""+tag).innerHTML = "<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><center><table><tr><td>Loading</td></tr></table></center></body>";
		}
 */   
    var xhr;
if (window.XMLHttpRequest)  {
    xhr = new XMLHttpRequest();
}
else
 if (window.ActiveXObject)
 {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer
 }
    xhr.onreadystatechange  = function()
    {
         if(xhr.readyState  == 4)
         {

              if(T == true)
              {
              	if(xhr.status  == 200)
              	{              
              		p = page.split('/');              
              		n = p[p.length-1];
              		n = n.replace(".txt",'');
              		fn = n.split('_');
              		n = fn[1];              //style=\"position:relative;width:"+ (WindowWidth()-260) +";height:95%;overflow-y: scroll;\"
              		//document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><table width=\""+ (WindowWidth()-260)+"\" height=\"5%\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td></tr></table><pre  name=\"code\" class=\""+CT+"\" >"  + xhr.responseText +"</pre></body>";
              		
              		//http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?code="+page+"&syn="+CT+"&DOC="+doc+"
              		//document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-200)+";\"><table style=\"position:relative;width:"+ (WindowWidth()-260) +";height:5%;\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td><td align=\"right\" style=\"font-family:Sans-serif;\"><a href=\"\">Contact</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr></table><iframe src=\"http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?copydisc="+page+"&DOC="+doc+"\" style=\"border: none;\" height=\"94%\" width=\"100%\" valign=\"top\"></iframe></body>";
              		
              		//document.getElementById(""+tag).innerHTML ="Error code " + page;
              	
              	}
              	else
              	{
              		document.getElementById(""+tag).innerHTML ="Error code " + xhr.status;
         	  	}
         	  }

         }
    };
   xhr.open("GET", ""+page,  true);
   xhr.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
   xhr.send(null);
}



function LoadContentFaqBox(doc,page,tag,T)
{
 /*
 if(T == true)
              {
    document.getElementById(""+tag).innerHTML = "<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><center><table><tr><td>Loading</td></tr></table></center></body>";
		}
 */   
    var xhr;
if (window.XMLHttpRequest)  {
    xhr = new XMLHttpRequest();
}
else
 if (window.ActiveXObject)
 {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer
 }
    xhr.onreadystatechange  = function()
    {
         if(xhr.readyState  == 4)
         {

              if(T == true)
              {
              	if(xhr.status  == 200)
              	{              
              		p = page.split('/');              
              		n = p[p.length-1];
              		n = n.replace(".txt",'');
              		fn = n.split('_');
              		n = fn[1];              //style=\"position:relative;width:"+ (WindowWidth()-260) +";height:95%;overflow-y: scroll;\"
              		//document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-260)+";\"><table width=\""+ (WindowWidth()-260)+"\" height=\"5%\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td></tr></table><pre  name=\"code\" class=\""+CT+"\" >"  + xhr.responseText +"</pre></body>";
              		
              		//http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?code="+page+"&syn="+CT+"&DOC="+doc+"
              		document.getElementById(""+tag).innerHTML ="<body style=\"style=\"position:relative;width:"+ (WindowWidth()-200)+";\"><table style=\"position:relative;width:"+ (WindowWidth()-260) +";height:5%;\" bgcolor=\"#CCCCCC\"><tr><td style=\"font-family:Sans-serif;\">"+n+"</td></tr></table><iframe src=\"http://www.system-engine.com/cgi-bin/LIBDOCXE.cgi?faq="+page+"&DOC="+doc+"\" style=\"border: none;\" height=\"94%\" width=\"100%\" valign=\"top\"></iframe></body>";
              		
              		//document.getElementById(""+tag).innerHTML ="Error code " + page;
              	
              	}
              	else
              	{
              		document.getElementById(""+tag).innerHTML ="Error code " + xhr.status;
         	  	}
         	  }

         }
    };
   xhr.open("GET", ""+page,  true);
   xhr.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
   xhr.send(null);
}





function LoadExtern(page,tag,T)
{
              if(T == true)
              {
    document.getElementById(""+tag).innerHTML = "<center><table><tr><td>Loading</td></tr></table></center>";
		}
    var xhr;
if (window.XMLHttpRequest)  {
    xhr = new XMLHttpRequest();
}
else
 if (window.ActiveXObject)
 {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");  // Internet Explorer
 }
    xhr.onreadystatechange  = function()
    {
         if(xhr.readyState  == 4)
         {

              if(T == true)
              {
              if(xhr.status  == 200)
              {
              document.getElementById(""+tag).innerHTML =""  + xhr.responseText +"";
              }
              else
              {
              document.getElementById(""+tag).innerHTML ="Error code " + xhr.status;
         	  }
         	  }

         }
    };
   xhr.open("GET", ""+page,  true);
   xhr.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" );
   xhr.send(null);
}

