var emilia_count =2;
var myID;
var newImage;
var newWidth;
var newHeight;
var newName;
var myDivs = document.getElementsByTagName('div');
var myRE = /\d\d\d\d\d\d/;
var myColor;

/*
var myDivFonts = new Array(myDivs.length);

	for (i=0;i<myDivs.length;i++)
  	{
	myID = (myDivs[i].getAttribute('id'));	
  	if (myRE.test(myID)) {
	
	myDivFonts[i] = document.getElementById(myID).getAttribute('color');

	}
	}
*/



function changeImage(imageID, newImage){

	document.images[imageID].src = newImage;
	return "FALSE";

}

function changeOnClick(myElement, myName, myImage, myWidth, myHeight){

document.getElementById(myElement).onclick=newOnClick;
newImage = myImage;
newWidth = myWidth;
newHeight = myHeight;
newName = myName;

//document.getElementById(myElement).attachEvent("onclick", newOnClick);
// the above action adds another event to the already present event
// so if you already have an onclick event, two events will now occur


}

function newOnClick()
{
 dynamicWindow(newName, newImage, newWidth, newHeight);
}





function dynamicWindow(TOPIC, IMAGE, WIDTH, HEIGHT){


 

	var myWindow = window.open('','Note', 'toolbar=no, menubar=no, resizable=no, width=' + WIDTH + ', height=' + HEIGHT );
	
	
        myDoc = myWindow.document;
	myDoc.open();
	myString = '<HTML><HEAD><TITLE>' + TOPIC + '</TITLE>';


	myString += ' <link rel="stylesheet" href="http://WWW.FUNGII.COM//styles-site.css" type="text/css" /></HEAD><BODY>';

	if(IMAGE == 'trebuchet') {

//	myString += "myDivFonts length: " + myDivFonts.length + "<br />";

	//*********************************************************
/*

for( var x = 0; x < theParagraph.attributes.length; x++ ) {
	if( theParagraph.attributes[x].nodeName.toLowerCase() == 'title' ) {
		window.alert( 'The value of the \'title\' attribute is: ' +
			theParagraph.attributes[x].nodeValue );
	}
}

*/

	for (i=0;i<myDivs.length;i++)
  	{
	myString += "Element #" + i + ": ";
	myID = (myDivs[i].getAttribute('id'));
	myColor = (myDivs[i].getAttribute('class'));
  	myString += myID;

	if (myRE.test(myID)) {
		myString += "! MATCH <br />";	
		myString += "Font family: " + myColor + "<br />";
                myDivs[i].setAttribute('class', 'myVerdana');
		myString += "Font family: " + (myDivs[i].getAttribute('class')) + "<br />";
	}
	myString += "<br />";
  	}


	myString += 'Hello<br />';

	}else {

	myString += '<IMG class="live_img"  onClick="self.close();" SRC="' + IMAGE + '">';

	}

	myString += '</BODY></HTML>';

	myDoc.write(myString);
	myDoc.close();

       
       
	myWindow.focus();
	




}

function closeTimer(theTime) {
setTimeout("self.close()", theTime);
 
   }

function OpenNewWin(url, title) {
   var new_win = window.open(url, title, 'width=640,height=650,scrollbars=auto');
   }

function OpenComments (c) {
    window.open(c, 'comments', 'width=640,height=480,scrollbars=yes');
}

function OpenTrackback (c) {
    window.open(c,  'trackback',
                    'width=640,height=480,scrollbars=yes,status=yes');
}

function OpenAbout(url) {
   var about_inf = window.open(url, "I_Fungii", "height=422 width=480 scrollbars=auto");
about_inf.focus();
}

function hideDiv(divID){ 

document.getElementById(divID).style.visibility='hidden';
	}

function showDiv(divID){ 

document.getElementById(divID).style.visibility='visible';
	}


function AboutClose(){ self.close();}

function nextEmilia(){ 
if (emilia_count==7){ self.close();};
document.getElementById("emilia_pic").src="http://www.fungii.com/images/emilia_0"+emilia_count+".jpg";
emilia_count++;

}

function insertSpChar(spchar) {

     
opener.document.getElementById('mainEntry').value += spchar;
opener.document.getElementById('mainEntry').focus();
self.close();

}

function setStyle(myTitle){

var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")[i]); i++){

if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")){
a.disabled = true;
}
 
if(a.getAttribute("title") == myTitle){
a.disabled = false;
}
}
}

function getCookie(NameOfCookie)
{

if (document.cookie.length > 0) 
{ 

begin = document.cookie.indexOf(NameOfCookie+"="); 
if (begin != -1)
{ 

begin += NameOfCookie.length+1; 
end = document.cookie.indexOf(";", begin);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(begin, end)); } 
}
return null; 
}


// *****************************************************


function setParagraphStyle(class){

// var paras = document.all.tags("P");
// for (i=0; i<paras.length; i++)
// paras(i).style.fontFamily = font;

	for (i=0;i<myDivs.length;i++)
  	{
	myID = (myDivs[i].getAttribute('id'));

	if (myRE.test(myID)) {

                myDivs[i].setAttribute('class', class);

	}
  	}


 }


 function setParagraphColor(color){

 
 var paras = document.all.tags("P");
 var first;
 first = document.styleSheets[0].rules[0]; 
 first.style.color = color;

 for (i=0; i<paras.length; i++){
    paras(i).style.color = color;
 }
 
 }

 function setParagraphSize(size){
 var i;
 var paras = document.all.tags("P");
 for (i=0; i<paras.length; i++)
    paras(i).style.fontSize = size+"em";

 }

 function setContentWidth(size){
 var i;
 var paras = document.getElementById("content");
 paras.style.width = size+"%";

 }

 function hideThis(mydiv){
 var i;
 var paras = document.getElementById(mydiv);
 paras.style.display = "none";
 
 }

 function unHide(mydiv){
 var i;
 var paras = document.getElementById(mydiv);
 paras.style.display = "inline";
 

 }

function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


