/**
 * @author andrewkett
 */
 var seoContent = new Array();
 var flashID;
 var jsReady = false;
 jQuery.fn.seoReplace = function(flashfile, flashvars, params, attributes, options){  

     //if any param objects are null create a new object no store default data in 
     if(attributes == null) var attributes = {};
     if(params == null) var params = {};
     if(flashvars == null) var flashvars = {};
     if(options == null) var options = {};
     
     
     this.each(function(){  
      //--
	  if (document.getElementById)
			var elementID = document.getElementById("navigation");
	  else if (document.all)
			var elementID = document.all["navigation"];
	  else if (document.layers)
			var elementID = document.layers["navigation"];
	  //---
	  var oldContent = innerXHTML(elementID);
	  //---
      var newId = "seo"+Math.floor(Math.random() * 1000000);
	  
      // could maybe use wrapInner( html )
      jQuery(this).html("<div id=\""+newId+"\">"+oldContent+"</div>");
      jQuery(this).css("overflow", "hidden");
      
      
      if (options && options.passcontent) {
        //set the default flashvars for the flash file
		
		flashvars.contentId = newId;
		
		setContent(newId,oldContent);
		
	  }else{
        
      }
      		
      //Set the default params of the flash file    
      if(!params.quality) params.quality = "high";
      if(!params.allowfullscreen) params.allowfullscreen = "true";
			if(!params.allowscriptaccess) params.allowscriptaccess = "always"; 
      if(!params.bgcolor) params.wmode = "transparent";
      
      
      //perform swfAddress replacement on new temporary div
      swfobject.embedSWF(flashfile, newId, '100%', '800px', "9.0.0", false, flashvars, params, attributes);
      
     });
       
 }
 
 
 function setActiveStyleSheet(title) {
  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") == title) a.disabled = false;
		}
	}
}

jQuery.seoReplace = function(flashfile, flashvars, params, attributes, options){  
   alert(flashfile);  
}  
 
function rollOverMenu(){
	jQuery('#navigation').attr('class','over');	
	jQuery('#navigation_container').attr('class','over');
	thisMovie(flashID).focus();
}

function rollOutMenu(){
	jQuery('#navigation').attr('class','out');
	jQuery('#navigation_container').attr('class','out');
	thisMovie(flashID).blur();
}

function setContent(id,content){
	seoContent[id] = content;
}

function thisMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
 	} else {
		return document[movieName];
	}
}

function getContent(id){
	flashID = id;
	thisMovie(id).sendToActionScript( seoContent[id] );
}

function focusFlash() {
	thisMovie(flashID).focus();
	thisMovie(flashID).blur();
}

function isReady() {
	return jsReady;
}
 
function menuInit() {
	jsReady = true;
}

function openRadio(pageURL) {
	var new_window = window.open(pageURL, 'radio_player', 'width=600,height=150');
	
	if(!new_window) {
		thisMovie(flashID).openWindowFromSwf(pageURL);
	}
	else {
		new_window.focus();
	}
}