function loadXMLDoc(url) 
{ 
   // branch for native XMLHttpRequest object 
    if (window.XMLHttpRequest) { 
        req = new XMLHttpRequest(); 
  //      req.onreadystatechange = processReqChange; 
        req.open("GET", url, true); 
        req.send(null); 
    // branch for IE/Windows ActiveX version 
    } else if (window.ActiveXObject) { 
        req = new ActiveXObject("Microsoft.XMLHTTP"); 
        if (req) { 
    //        req.onreadystatechange = processReqChange; 
            req.open("GET", url, true); 
            req.send(); 
        } 
    } 
} 

function processReqChange() 
{ 
    //alert (reg.readyState); 
   // only if req shows "complete" 
   if (req.readyState == 4) { 
        // only if "OK" 
        if (req.status == 200) { 
             response  = req.responseXML.documentElement; 
            method    = response.getElementsByTagName('method')[0].firstChild.data; 
           result    = response.getElementsByTagName('result')[0].firstChild.data; 
          //alert (method) //checkName('',result) 
          eval(method + '(\'\', result)'); 
       } else { 
            alert("There was a problem retrieving the XML data:\n" + req.statusText); 
        } 
    } 
}    


function toggle(id,action) {
	if (document.getElementById)
			{
			var	theitem = document.getElementById(id);
			
			if (action == 'maximised') {
				theitem.style.display = 'block';				
				}
			else {
				theitem.style.display = 'none';				
				}				

			document.getElementById(id +'-control').className = action;
//			window.open('http://storytellers.reflex.net/silent_switcher.php?set='+ id +'&action='+ action);
		/*	loadXMLDoc('http://www.the-storytellers.com/silent_switcher.php?set='+ id +'&action='+ action); */
			}
}


function maximise(id) {
	if (document.getElementById)
			{
			var	theitem = document.getElementById(id);
		
			theitem.style.display = 'block';
			document.getElementById(id +'-control').className = 'maximised';
			/*loadXMLDoc('http://www.the-storytellers.com/silent_switcher.php?set=maximised'); */
			}
}


/*

Image fade code by Clagnut:
http://clagnut.com/sandbox/imagefades/

*/

document.write("<style type='text/css'>#bannerimage {background: #A5CD2C; visibility:hidden;}</style>");



function initImage() {
	imageId = 'bannerimage';
	if (image = document.getElementById(imageId)) {
	setOpacity(image, 0);
	image.style.visibility = "visible";
	fadeIn(imageId,0);
	}
}

function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			//opacity += 10;
			opacity += 7;
			//window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 60);
		}
	}
}
function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

function externalLinks() {
  if (!document.getElementsByTagName) return;
  var anchors = document.getElementsByTagName("a");
  for (var i=0; i<anchors.length; i++) {
    var anchor = anchors[i];
    if (anchor.getAttribute("href") &&
      anchor.getAttribute("rel") == "external")
      anchor.target = "_blank";
    }
}


window.onload = function() {
	initImage();
	externalLinks();
}





