/***********************************************
* Dynamic Ajax Content- � Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var loadedobjects=""
var rootdomain="http://"+window.location.hostname

//this function is for the html links, it needs the return false at the end,  
function ajaxpage(url, containerid){
	
	var page_request = false;


	if (window.XMLHttpRequest) // if Mozilla, Safari etc
			page_request = new XMLHttpRequest()
		
		else if (window.ActiveXObject){ // if IE

		try {
		
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
			} 
		catch (e){

		try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch (e){}
		}
	}
else

	return false	
	page_request.onreadystatechange=function(){
	loadpage(page_request, containerid)
	


}



page_request.open('GET', url, true)

page_request.send(null)  

//this is working on ff nd ie!!!!!!!!!!!!
//loadobjs('secondarylinks.js')
//need this for html links
return false;


}

//this function is for the flash links, it doesnt need the return false at the end,  
function ajaxpageFlash(url, containerid){
	
	var page_request = false

	if (window.XMLHttpRequest) // if Mozilla, Safari etc
			page_request = new XMLHttpRequest()
		
		else if (window.ActiveXObject){ // if IE

		try {
		
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
			} 
		catch (e){

		try{
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch (e){}
		}
	}
else
	return false
	page_request.onreadystatechange=function(){
	loadpage(page_request, containerid)

}
page_request.open('GET', url, true)
page_request.send(null)  


//dont need this for flash links
//return false;

}


function loadpage(page_request, containerid){


	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
		document.getElementById(containerid).innerHTML=page_request.responseText
		//get all the links ready again
		loadAllLinks();
		
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
//if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
	fileref=document.createElement('script')
	fileref.setAttribute("type","text/javascript");
	fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
		fileref=document.createElement("link")
		fileref.setAttribute("rel", "stylesheet");
		fileref.setAttribute("type", "text/css");
		fileref.setAttribute("href", file);
	}
}
	if (fileref!=""){
		document.getElementsByTagName("head").item(0).appendChild(fileref)
		//loadedobjects+=file+" " //Remember this object as being already added to page
		}
		
	}
//}


//submit (might have to change this yet)
function prepareSubmit() {
	document.usrLogIn.action ="javascript:ajaxpageFlash('pages/one.html','container')";
}

//generic prepare links function
function prepareAllLinks(tagID, tagType, loadInTo) {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById(tagID)) return false;
  var ajaxLinks = document.getElementById(tagID);
  var links = ajaxLinks.getElementsByTagName(tagType);
  for ( var i=0; i < links.length; i++) {
    links[i].onclick = function() {
     return ajaxpage(this, loadInTo);
	}
    links[i].onkeypress = links[i].onclick;
  } 
}

function showPic(whichpic) {
  if (!document.getElementById("placeholder")) return true;
  var source = whichpic.getAttribute("href");
  var placeholder = document.getElementById("placeholder");
  placeholder.setAttribute("src",source);
  if (!document.getElementById("description")) return false;
  if (whichpic.getAttribute("title")) {
    var text = whichpic.getAttribute("title");
  } else {
    var text = "";
  }
  var description = document.getElementById("description");
  if (description.firstChild.nodeType == 3) {
    description.firstChild.nodeValue = text;
  }
  return false;
}

function prepareGallery() {
  if (!document.getElementsByTagName) return false;
  if (!document.getElementById) return false;
  if (!document.getElementById("imagegallery")) return false;
  var gallery = document.getElementById("imagegallery");
  var links = gallery.getElementsByTagName("a");
  for ( var i=0; i < links.length; i++) {
    links[i].onclick = function() {
      return showPic(this);
	}
    links[i].onkeypress = links[i].onclick;
  }
}


//newWindow function
function doPopups() {
  if (!document.getElementsByTagName) return false;
  var links=document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("popup")) {
      links[i].onclick=function() {
      // Next two lines should be on one line
        window.open(this.href, "","");
        return false;
      }
    }
  }
}


//mediaPopup function
function MediaPopups() {
  if (!document.getElementsByTagName) return false;
  var links=document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("listen")) {
      links[i].onclick=function() {
      // Next two lines should be on one line
       window.open(this.href, "player", "toolbars=0,width=335,height=350,status=0,menubar=0,scrollbars=0,resizable=0");
	return ajaxpage("media_blank.php", "rightCol2")
        return false;
      }
    }
  }
}
//setup Toggle
function stretch(){
		if (!document.getElementsByClassName('stretcher')) return false;
		//we define two arrays, containing our toggles and divs.
		var myDivs = document.getElementsByClassName('stretcher');
		var myLinks = document.getElementsByClassName('stretchtoggle');

		//then we create the effect.
		var myAccordion = new fx.Accordion(myLinks, myDivs, {opacity: true});


		//then we create the effect.
		//var myAccordionMain = new fx.Accordion(myLinksMain, myDivsMain, {opacity: true});
}


//mediaPopup function
function MediaPopups2() {
  if (!document.getElementsByTagName) return false;
  var links=document.getElementsByTagName("a");
  for (var i=0; i < links.length; i++) {
    if (links[i].className.match("listen2")) {
      links[i].onclick=function() {
      // Next two lines should be on one line
       window.open(this.href, "player", "toolbars=0,width=335,height=350,status=0,menubar=0,scrollbars=0,resizable=0");
	//return ajaxpage("media_blank.php", "rightCol2")
        return false;
      }
    }
  }
}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}


//put all functions in here to prpare different link
//to be called on body load
function loadAllLinks() {

	prepareAllLinks("wrapper","a","content");
	//prepareAllLinks("primary","a","container");
prepareGallery();
doPopups();
MediaPopups();
MediaPopups2();
stretch();
}

//pop-up window script
function listen()
    {
window.open("listen.php","_blank","toolbars=0,width=335,height=350,status=0,menubar=0,scrollbars=0,resizable=0");
         }





//prepares the on window load function
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}




//calls the functions to load on page load
//prepare footerlinks
//addLoadEvent(prepareFooterLinks);
//addLoadEvent(prepareArchiveLinks);
//addLoadEvent(prepareNewsArchive);
//addLoadEvent(prepareMainArchive);
//addLoadEvent(loadAllLinks);
var df = new domFunction(loadAllLinks, {'a' : 'tag'});