// JavaScript Document

var site_root = 'http://www.blacklabeldetail.com';


//	Browser d-tect
var w3c = (document.getElementById) ? true : false;
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false;

// Array and custom class
var aFlashInfo = new Array();

function FlashEmbedObj(width, height, source, container)
{
	this.width = width;
	this.height = height;
	this.source = source;
	this.container = container;
}


//var testFEO = new FlashEmbedObj(444, 555, "blackLabel.swf", "flashContainer");


//	Init variables - set to true on page to have them execute
var is_flash = false;
var is_flashnav = false;
var is_index = false;
var pw_key;
var pw_form;

//if (w3c) {
//	document.write('<style type="text/css">#flashContent { visibility: hidden; } </style>');
//}


//	Init function
function init() {
	/* *************************************************** */
	/* ****************** Flash Control ****************** */
	

	if (hasRightVersion) {
		//insertFlash("blackLabel.swf?thisPage=overview",430,780,"flashContent");
		for(i=0; i < aFlashInfo.length; i++)
		{
			
			insertFlash(aFlashInfo[i].source,aFlashInfo[i].height,aFlashInfo[i].width,aFlashInfo[i].container);
		}
		/*
		if (is_flashnav && is_flash) {
			insertFlash(flashnav_swf,130,415,"flashNavigator"); // Insert flashnav_swf
			setTimeout("runActivity()",1000); // Insert activity after 1000 milliseconds (1000 milliseconds = 1 second)
			
		} else	if (is_flashnav) {
			insertFlash(flashnav_swf,130,415,"flashNavigator");
			
		} else	if (is_flash) {
			runActivity();
		}
		*/
		
	} else {
		/*
		if (document.getElementById('flashContent')) 
		{
			document.getElementById('flashContent').style.visibility = 'visible';
		}
		*/
			
			window.location = "updateFlash.html";
		
	}
	//setLinks();
}

//	If browser is good, run onload function
if (w3c) { window.onload=init; }





function setLinks() {
	var all_links = document.getElementsByTagName('A');
	var default_params = 'toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=780,height=550';
	
	for (var bb=0; bb<all_links.length; bb++) {		
		if (all_links[bb].target.toLowerCase() == 'webrangerslink') {
			all_links[bb].onclick = function() {
				if (this.firstChild.nodeValue.toLowerCase() == 'how to use this site') {
					popupWindow(this.href, this.target, 'status=yes,scrollbars=yes,resizable=yes,width=675,height=400');
					return false;
				} else {
					popupWindow(this.href, this.target, default_params);
					return false;
				}
			}
		}
		if (all_links[bb].target.toLowerCase() == 'externallink') {
			all_links[bb].onclick = function() {
				if (confirm('You are about visit a page outside of the WebRangers website. Are you sure you want to continue?')) {
					popupWindow(this.href, this.target, default_params);
				}
				return false;
			}			
		}
	}
}

//	Create JavaScript pop-ups for related links at the bottom of pages
function setRelatedLinks() {
	var related_links_list = document.getElementById('moreInfoLeft');
	var related_links = related_links_list.getElementsByTagName('A');
	var window_params = 'location=yes,menubar=no,toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=740,height=450';
	
	for (var aa=0; aa<related_links.length; aa++) {
		related_links[aa].onclick = function() {
			popupWindow(this.href, this.target, window_params);
		}
	}
}

//	Popup window code
function popupWindow(url, target, features) {
	var page_position = (parseInt(navigator.appVersion) > 3) ? 'left=0,top=0,screenX=0,screenY=0,' : "";
	var popup_features = 'menubar=yes,status=yes,toolbar=yes,scrollbars=yes,resizable=yes,width=785,height=480';

	if (isUndefined(features)) {
		features = popup_features;
	}
	if (isUndefined(target)) {
		target = '_blank';
	}
	var the_window = window.open(url, target, page_position+features);
	the_window.focus();
	return the_window;
}

function linkPopup(src, features) {
	return popupWindow(src.getAttribute('href'),src.getAttribute('target') || '_blank',features);
}

//	Utility function [currently used in popupWindow()]
function isUndefined(v) { 
	//	Returns true if [v] is not defined, false otherwise
	//	IE 5.0 does not support the undefined keyword, so we cannot 
	//	do a direct comparison such as v===undefined.
	var undef;
	return v===undef;
}
//	End Popup window code







//	FLASH PLAYER CHECK
//	Checks for Flash 4,5,6,7, 8 plug-in. This works with Netscape, Mozilla, IE Win and IE5 Mac.
//	Variable [hasRightVersion] will be set to true or false
var hasFlash2 = false;
var hasFlash3 = false;
var hasFlash4 = false;
var hasFlash5 = false;
var hasFlash6 = false;
var hasFlash7 = false;
var hasFlash8 = false;

var requiredVersion = 8;
var maxVersion = 8;
var actualVersion = 0;
var hasRightVersion = true;	


if (navigator.plugins) {
	if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]
	&& navigator.mimeTypes["application/x-shockwave-flash"] 
	&& navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {		
		var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
		var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;
		var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
		
		hasFlash4 = flashVersion == 4;
		hasFlash5 = flashVersion == 5;
		hasFlash6 = flashVersion == 6; 
		hasFlash7 = flashVersion == 7; 
		hasFlash8 = flashVersion >= 8;
	}
}

//	Write VBScript on IE Windows
if (isIE && isWin){
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  	document.write('on error resume next \n');
  	document.write('hasFlash4 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
	document.write('hasFlash5 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');
	document.write('hasFlash6 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');
	document.write('hasFlash7 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');	
	document.write('hasFlash8 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');		
  	document.write('</SCR' + 'IPT\> \n');
}
for (var i=2; i <= maxVersion; i++) {  
	if (eval("hasFlash" + i) == true) {
		actualVersion = i;
	}
}
if (actualVersion >= requiredVersion) {
	hasRightVersion = true;
}//	End Flash Player check

hasRightVersion = true;	

//	This function returns the <object> and <embed> tags in variable [oeTags]
function makeFlashTags(the_swf,the_height,the_width) {
	if (hasRightVersion) {
		var flashTag;
		if (isIE && isWin) {
			flashTag = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'
			+ 'width="'+the_width+'" height="'+the_height+'"'
			+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
			+ '<param name="movie" value="'+the_swf+'" />'
			+ '<param name="play" value="true" />'
			+ '<param name="quality" value="high" />'
			+ '<param name="menu" value="false" />'
			+ '</object>';
		} else {
			flashTag = '<embed src="'+the_swf+'"'
			+ 'width="'+the_width+'" height="'+the_height+'"'
			+ 'play="true"'
			+ 'quality="high"'
			+ 'menu="false"'
			+ 'type="application/x-shockwave-flash"'
			+ 'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">'
			//	+ 'loop="false"'
			+ '</embed>';			
		}
		return flashTag;
	}
}

//	This function returns the <object> and <embed> tags in variable [oeTags]
function makeUpdateMessage(the_swf,the_height,the_width) {
	if (hasRightVersion) {
		var updateTag;
		
			updateTag = '<div class="content"><p>You\'re missing out!</p><p>To get the most out of this site, you\'ll need the latest Flash Player </div>'
			+ 'width="'+the_width+'" height="'+the_height+'"'
			+ 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">'
			+ '<param name="movie" value="'+the_swf+'" />'
			+ '<param name="play" value="true" />'
			+ '<param name="quality" value="high" />'
			+ '<param name="menu" value="false" />'
			+ '</object>';
		
		return updateTag;
	}
}



//	This function swaps innerHTML of [the_container] with makeOETags()
function insertFlash(the_swf,the_height,the_width,the_container) 
{
	
	if (hasRightVersion) 
	{
		document.getElementById(the_container).style.height = the_height;
		document.getElementById(the_container).style.visibility = 'hidden';
		document.getElementById(the_container).innerHTML = makeFlashTags(the_swf,the_height,the_width);
		document.getElementById(the_container).style.visibility = 'visible';
	}
}

//	This function swaps innerHTML of [the_container] with makeOETags()
function insertUpdateMessage(the_swf,the_height,the_width,the_container) 
{
	
	if (the_swf == "blacklabel.swf") 
	{
		document.getElementById(the_container).style.height = the_height;
		document.getElementById(the_container).style.visibility = 'hidden';
		document.getElementById(the_container).innerHTML = makeUpdateMessage(the_swf,the_height,the_width);
		document.getElementById(the_container).style.visibility = 'visible';
	}
	else
	{
		document.getElementById(the_container).style.height = the_height;
		document.getElementById(the_container).style.visibility = 'hidden';
		document.getElementById(the_container).innerHTML = makeUpdateMessage(the_swf,the_height,the_width);
		document.getElementById(the_container).style.visibility = 'visible';
	}
}


