/* Basic javascipt functions
Created by Laszlo Naszodi lasz@scriptwell.net

1. Header functions
2. Shadow dropping letters 
3. Footer for all pages
4. New roundborder functions
*/
function isNull(obj){return (obj==null)||(obj==undefined)
}

/*Header functions ver. 1.4 050412  */
function makeCurvyLetters(){
with(document){
    write('<div style="position:absolute;top:-12px;left:0px;color:#603;text-align:right; font-style:italic;');
    write('font-family:Times New Roman;font-weight:bold">');
	txtCurvy = "                                                           S c r i p  t W   e  l l .n  e  t          ";
	txtCurvy = txtCurvy.split('');// make an array of characters
	len = txtCurvy.length; 
	curvyWidth =130;
	curvyHeight = -50;
	xpos = 120;
	ypos = 60;
	var step = 2*Math.PI/len; 
	for(i=0; i<len; i++){
		fntSize = curvyHeight * Math.sin(i*step);
		y = ypos + curvyHeight;
		x = xpos + curvyWidth * Math.cos(i*step);
		if (fntSize<5) fntSize=5;
		fntSize = Math.round(fntSize/1.7 +.5);
		write('<span style="width:auto;height:auto;position:absolute;top:'+y+'px;left:'+x+'px;');
		write('font-size:'+fntSize+'pt">'+txtCurvy[i]+'</span>');
	}
	write('</div>');
}//end with
}//end function makeHeader()

function findSelected(){//returns the index of current tab
var addr=''+document.location;
addr=addr.toLowerCase()
if(addr.indexOf('default.html')==-1){//find tab index
  for (var i=1; i<Items.length; i++){
	if(addr.indexOf(Items[i].toLowerCase())>-1) return i;
  }//end for
}//end if
return 0
}

function setCurrentButton() {
	var cb=findSelected();
	id='btn'+cb;
	with(document.getElementById(id).style){
		border="thin inset";
	}
	id='anc'+cb;
	with(document.getElementById(id).style){
		color="#c09";
		background="#ddd"
	}
}
/*End header functions */

/* Shadow dropping letters
Have this file in the script folder.
Put a <script src="script/shady.js" /> tag in the <head> section and
another script tag in the body where you want to display a shady letter. 
Examples:	<script>shady('G')</script>. 
(narrow I)	<script>shady('I', 22)</script>. 
(wide M)	<script>shady('M', 38)</script>. 
*/
/*function shady(ltr, shift){//Suggested shift for I:22; for M and W:38
 if (isNull(shift))	var shift=30;//Default for medium width letters
 var shiftShadow=shift/5-3;
 var edge=6-shift;
 with (document){
	write('<span style="float:left;font:bold 34pt Bookman Old Style, Times New Roman;');
//	write('margin-left='+edge+'px;line-height:75%">');
	write('margin-left:0px;line-height:75%">');
	write('<span style="position:relative;top:-4px;left:'+shift+'px; color:black; z-index:2">');
	write(ltr+'<\/span>');
	write('<span style="position:relative;top:-2px;left:'+shiftShadow+'px; color:gray; z-index:1">');
	write(ltr+'<\/span><\/span>')
 }
 }
 */
 function shady(letter){
     document.write('<span class="d3"><span class="front">'+letter+'</span>');
    document.write('<span class="back">'+letter+'</span></span>');
}/* End Shadow dropping letters */

/* Footer functions */
function footer(prev,next,dtd) {
 if(isNull(dtd)) dtd='html';
 with(document){
	SteadyLinks(prev,next, lang);
	write('<p style="text-align:center;font-size:14px;" >');
	write('<img src="images/XBrowser41.gif" height="21" width="70"');
	write(' alt="Cross-browser award by Laszlo Naszodi"> &nbsp;');
	write('This page has been tested with IE6 &amp; 7, FF1.5 &amp; 2 and Opera7.21 &amp; 9.');
	write(' &nbsp;<img src="images/');
	if(dtd.toLowerCase()=='html')	write('valid-html401.png" alt="Valid HTML 4.0!"');
	if(dtd.toLowerCase()=='xhtml')	write('valid-xhtml101.png" alt="Valid XML"');
	write(' height="21"><\/p>');
 }
}//end function footer()

function SteadyLinks(prev, next, lang) {
	var firstlink='cover.html';
	var firsttitle='cover page';
	var prevtitle='Prev';
	var contenttitle='Content';
	var nexttitle='Next';
	var lastlink='backcover.html';
	if (lang=="Hung") {
		firstlink='bevezet.html';
		firsttitle='Bevezeto';
		prevtitle='El&otilde;z&otilde;';
		contenttitle='Tartalom';
		nexttitle='K&ouml;v';
		lastlink='szerz.html';
	}
 with(document){
	writeln('<div class="SteadyLinks" style="font-size:12px">');
	if(prev>''){
		write('<a class="button" href="'+firstlink+'" title="'+firsttitle+'" target="_self">&nbsp;&lt;&lt; <\/a>&nbsp;'); 
		write('<a class="button" href="'+prev+'" title="previous article" target="_self">&nbsp;&lt; '+prevtitle+' <\/a>&nbsp;')
	} 
	write('<a class="button" href="TOC.html" id="TOC" title="table of contents" target="_self">&nbsp;'+contenttitle+' <\/a>&nbsp;'); 
	if(next>''){
   		write('<a class="button" href="'+next+'" title="next article" target="_self">&nbsp;'+nexttitle+' &gt; <\/a>&nbsp;'); 
		write('<a class="button" href="'+lastlink+'" title="back cover" target="_self">&nbsp;&gt;&gt; <\/a>')
	}
	writeln('<\/div>');
	var url=''+document.location;
	if(url.indexOf('TOC') != -1){
 	  with(getElementById('TOC').style){
		border="thin inset";
		color="black";
		background="#ddd"
	  }//end with
	}//end if
 }//end with
}//end function SteadyLinks()

function storefooter(withvalid) {
//withvalid==null: show second line as if withvalid was 'HTML'
//withvalid==false:don't show second line
//withvalid=='HTML':show second line with valid-HTML logo
//withvalid=='XML':show second line with valid-XML logo
if (isNull(withvalid)) withvalid='HTML';
 with(document){
 //about line
	write('<div id="footer">');
	write('<div class="aboutline" style="font-size:12px">');
	write('| Webmaster: <a href="http://www.scriptwell.net/resum_us.htm" target="_blank">'); 
	write('LN</a> | Email: ');
	write('<a href="mailto:lasz@scriptwell.net">lasz@scriptwell.net</a> | Home: ');
	write('<a href="http://www.scriptwell.net/" ');
	write('target="_top">www.scriptwell.net</a> |'); 

	lastModifiedDate();
	write('<\/div>');
  if(withvalid!=false){
  //x-browser and valid html line
	write('<img src="images/xbrowser.png" alt="Cross-Browser Award" height="31" width="103" \/> &nbsp;');
	write('<span style="vertical-align:super;font-size:12px">');
	write('This page has been tested with IE 6.0, Netscape 7.1, Opera 7.21 and Firefox 1.0.6.');
	write('<\/span>');
	if(withvalid.toLowerCase()=='html')
		write('&nbsp;<img src="images/valid-html40.png" alt="Valid HTML 4.0!" height="31" width="88">');
	if(withvalid.toLowerCase()=='xhtml')
		write('&nbsp;<img src="images/valid-xhtml10.png" alt="Valid XML" height="31" width="88">');
	write('<\/div>');
  }//end if
 }//end with
}//end function storefooter()

function date_Monddyyyy(date) {
var d=date.getDate();//does not work in NS6
var m=date.getMonth()+1;
var y=date.getYear();

// handle different year values returned by IE and NS in the year 2000.
if(y>=2000)y -=2000;//IE
if(y>= 100)y -= 100;
// could use splitString() here but the following method is more compact
var mmm=
(1==m)?'Jan':(2==m)?'Feb':(3==m)?'Mar':( 4==m)?'Apr':( 5==m)?'May':(6==m)?'Jun':
(7==m)?'Jul':(8==m)?'Aug':(9==m)?'Sep':(10==m)?'Oct':(11==m)?'Nov':'Dec';
return ""+mmm+" "+(d<10?"0"+d:d)+", "+"20"+(y<10?"0"+y:y);
}  //end function date_Monddyyyy(date) *********************

function date_lastmodified() {// get last modified date of the current document.
var s="Unknown";
var lmd=document.lastModified;
var d1;
if(0!=(d1=Date.parse(lmd))){//Nescape provides today's date
	s=""+date_Monddyyyy(new Date(d1));
}
return s;
} //end function date_lastmodified() ******************

function lastModifiedDate(){
// writes the last modified date of the center page
var str=document.lastModified;
if (document.all) {//IE
	str=date_lastmodified() ;
}
else {//not (document.all) like in NS6.
	if (str.indexOf(",")!=str.lastIndexOf(",")) {//cut the day:
		str=str.substring(str.indexOf(",")+2,str.length);
	}
	str=str.substring(0,str.length-9);//cut time
}
if(str.indexOf(":")>0) {// hour: in string
	colonLoc = str.indexOf(":");
	str=str.substring(0, colonLoc - 3);
}

document.write(' Updated: '+str+'&nbsp;|');
} //end function lastModifiedDate() **********
/* End Footer functions */

/*New roundborder functions */
function topRoundFrame() {//Displays the right and the bottom of the round border
  with (document) {
	writeln('<div class="roundBox">');
	writeln(' <div class="roundedge">');
	write  ('     <img src="images/topleft.png" style="vertical-align:text-top" ');
	write  ('         alt="/" /><img class="horizline" src="images/graydot.png" ');
	writeln('         style="vertical-align:text-top;" alt="." />');
	write  ('</div>');
	writeln('<div style="border-left:solid 1px #ccc; border-right:solid 1px #ccc;">');
  }//end with
} //end function topRoundFrame()

function bottomRoundFrame() {//Displays the right and the bottom of the round border
  with (document) {
	writeln('&nbsp;');
	writeln(' </div>');
	write ('<div class="roundedge"');
	write ('    style="background:url(images/bottomright.png) no-repeat top right">');
	write ('    <img src="images/bottomleft.png"');
	write ('        style="vertical-align:top" alt="/" /><img class="horizline"');
	write ('        src="images/graydot.png"');
	writeln('        style="vertical-align:bottom" alt="." />');
	writeln('  </div>');
	writeln('</div>');
  }//end with
} //end function bottomRoundFrame()

function RoundStyle(horizWidth, curveWidth){
/*if(isNull(curveWidth)) curveWidth=15;
if(isNull(horizWidth)) horizWidth=700;*/
  with (document) {
	writeln('<style media="screen" type="text/css">');
	writeln('.roundedge {width:100%; height:15px; line-height:100%}');
	writeln('.topleft {vertical-align:top}');
	writeln('.horizline {width:670px; height:1px}');
	writeln('.roundBox {width:700px; font-size:14px;');
	writeln('background: url(../images/topright.png) no-repeat top right}');
	writeln('</style>');
  }//end with
} //end function scriptRoundStyle()

RoundStyle();
var strOptions='width=750, height=250, toolbar=no, top=150,left=100,location=no,scrollbars=no';//for window.open()

