/*********************************************** 
		Javascript for Roxtons
***********************************************/	
document.write('<link rel="StyleSheet" href="/roxtonsAssets/css/roxtonsJavascript.css" type="text/css" media="screen" />');
/******************************************************************************************
Global variables
******************************************************************************************/
var assets = "/roxtonsAssets/";
var ua = navigator.userAgent.toLowerCase();
/******************************************************************************************
set bolean to detect safari on mac - the flash text does not seem to work with 
the opacity background on any gecko browsers on mac
******************************************************************************************/
macNotSafari = (ua.indexOf("windows") == -1)&&(ua.indexOf("safari") == -1)? true:false; 
/******************************************************************************************
Flash detect. boolean true/false if installed and version number accessed via flash.version
******************************************************************************************/
if (navigator.plugins && navigator.plugins.length) {
	for (x=0; x < navigator.plugins.length; x++) {
		if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
			var flash = new Object();			
			flash.version = eval(navigator.plugins[x].description.split('Shockwave Flash ')[1].split('.')[0]);					
			break;
		}
	}
}
else if (window.ActiveXObject) {
	for (x = 2; x <= 20; x++) {
		try {
			oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
			if(oFlash) {
				var flash = new Object();				
				flash.version = x;
			}
		}
		catch(e) {}
	}
}
if(flash && !macNotSafari) {
	document.write("<link rel=\"StyleSheet\" href=\""+assets+"/css/roxtonsEnhanced.css\" type=\"text/css\" media=\"screen\" />");
}
/******************************************************************************************
On body load run these configuration functions
@param 		bodyRef 		object reference of the entire body of the page
******************************************************************************************/
function fnInit(bodyRef) {
	fnFRT();
	fnFbFRT();
}
/******************************************************************************************
Find all <h2> tags with class 0f "flashTxt" and replace content with flash movie with "Myriad Roman" font.
Will not run on Firefox Mac.
******************************************************************************************/
function fnFRT() {
	if(flash && !macNotSafari) {
		var topHeadings = document.getElementsByTagName("H2");
		var text, swf;
		
		for (i=0;i<topHeadings.length;i++) {
			if (topHeadings[i].className=="flashTxt") {		//look for class "flashTxt"	
				text 	= escape(topHeadings[i].innerHTML); 	// Grab text and encode
				swf		= fnMakeFlash(assets+"swf/flashTxt.swf?t="+text,270,20);
				topHeadings[i].innerHTML = "<span class=\"hide\">"+topHeadings[i].innerHTML+"</span>"+swf;
				topHeadings[i].style.visibility = "visible";
			}
		}
	}
}


/******************************************************************************************
Find all <h2> tags with class 0f "fbFlashTxt" and replace content with flash movie with "Myriad Roman" font.
Will not run on Firefox Mac.
******************************************************************************************/
function fnFbFRT() {
	if(flash && !macNotSafari) {
		var topHeadings = document.getElementsByTagName("H2");
		var text, swf;
		
		for (i=0;i<topHeadings.length;i++) {
			if (topHeadings[i].className=="fbFlashTxt") {		//look for class "flashTxt"	
				text 	= escape(topHeadings[i].innerHTML); 	// Grab text and encode
				swf		= fnMakeFlash(assets+"swf/fbFlashTxt.swf?t="+text,270,20);
				topHeadings[i].innerHTML = "<span class=\"hide\">"+topHeadings[i].innerHTML+"</span>"+swf;
				topHeadings[i].style.visibility = "visible";
			}
		}
	}
}





/********************************************************************************

Name: 				make flash
Description:		Return flash code. Fixes Eolas update for IE as well.
@param	swf			String path to swf file
@param	width		Number value of movie width
@param	height		Number value of movie height

*********************************************************************************/

function fnMakeFlash(swf,width,height) {	
	return '<embed src="'+swf+'" menu="false" width="'+width+'" height="'+height+'" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" />';	
}


/********************************************************************************
 
Name:     Flash plugin detect
 
*********************************************************************************/
var flashdetect = false;
function fnFlashDetect() {
 if (navigator.plugins && navigator.plugins.length) {
  for (x=0; x < navigator.plugins.length; x++) {
   if (navigator.plugins[x].name.indexOf('Shockwave Flash') != -1) {
     flashdetect = true;      
    break;
   }
  }
 }
 else if (window.ActiveXObject) {
  for (x = 2; x <= 20; x++) {
   try {
    oFlash = eval("new ActiveXObject('ShockwaveFlash.ShockwaveFlash." + x + "');");
    if(oFlash) {
     flashdetect = true;  
    }
   }
   catch(e) {}
  }
 }
}
fnFlashDetect(); // run on file load; 


/********************************************************************************
 
Name:     Flash embed
Description:  Writeout flash code. Fixes Eolas update for IE as well.
@param swf  String path to swf file
@param width     Number value of movie width
@param height    Number value of movie height
@param alternateContent String of HTML to be served if flash is not installed
 
*********************************************************************************/
 
flash = new Object();
flash.insert = function(swf,width,height) {
	swf = swf.replace(/\./g,"%2E") // encode periods as %2e	
	if(flashdetect) { 	
		flashObject = '<embed src="'+swf+'" menu="false" quality="high" width="'+width+'px" height="'+height+'px" type="application/x-shockwave-flash" wmode="transparent" salign="T" pluginspage="http://www.macromedia.com/go/getflashplayer" />'
		document.write(flashObject);
	} else {
		//flashObject = alternateContent;
		fnShowNoFlash();
	} 
}


function fnShowNoFlash() {
	if (document.getElementById("noFlashContent")) {
		document.getElementById("noFlashContent").style.display = "block";
	}
	if (document.getElementById("noFlashContent1")) {
		document.getElementById("noFlashContent1").style.display = "block";
	}
	if (document.getElementById("noFlashContent2")) {
		document.getElementById("noFlashContent2").style.display = "block";
	}
	if (document.getElementById("noFlashContent3")) {
		document.getElementById("noFlashContent3").style.display = "block";
	}
	if (document.getElementById("noFlashContent4")) {
		document.getElementById("noFlashContent4").style.display = "block";
	}		
}




/********************************************************************************

Name: 				Thumb Show/Hide
Description:		Takes path to linked image file from it's tag, and replaces target image with this one.
@param	this		Path to linked image file

*********************************************************************************/

function fnThumbSh(targ) {
	var anchors = document.getElementById("venueThumbs").getElementsByTagName("A");
	
	document.getElementById("shTarg").getElementsByTagName("img")[0].src = targ.href;		
	
	if (document.all) {
		for (i=0;i<anchors.length;i++) {
			targ.parentNode.parentNode.getElementsByTagName("IMG")[i].style.filter = "alpha(opacity=100)";		
			}	
		targ.getElementsByTagName("IMG")[0].style.filter = "alpha(opacity=50)";
		}
	else {
		for (i=0;i<anchors.length;i++) {
			targ.parentNode.parentNode.getElementsByTagName("IMG")[i].style.opacity = "1";			
			}	
		targ.getElementsByTagName("IMG")[0].style.opacity = "0.5";
		}
	}


/* print function */
function fnPrint() {
	window.print();	
}