﻿function Accessible(){
 //var t = '<img title="Go Search" onmouseover="this.src=\'/PSImages/branding/searchActive.jpg\'" onfocus="this.src=\'/PSImages/branding/searchActive.jpg\'" onmouseout="this.src=\'/PSImages/branding/search.jpg\'" onblur=="this.src=\'/PSImages/branding/search.jpg\'" alt="Go Search" src="/PSImages/branding/search.jpg" style="border-width:0px;" />';
 //document.getElementById('ctl00_SearchBox_S83C543AE_go').innerHTML = t;
}

function UpdateFormDigest( a, b){
   return;
}

function _spFormOnSubmitWrapper(){
   return true;
}

var FlashReplace = {
   
	elmToReplace : null,
	flashIsInstalled : null,
	defaultFlashVersion : 7,
	replace : 
function FlashReplace(elmToReplace, src, id, width, height, version, params){
		 //alert(showFlash);
		 if(showFlash == true){
		 var soundOn = false;
  
  		 var cookieValue = readCookie('ProjectScotlandSound');
  	 	 if (cookieValue != null){
		 soundOn = true;
  		 }

		 if(soundOn == true){
		  src = '/Flash/mute' + src;
		 }else{
		  src = '/Flash/' + src;
		 }
		
		this.elmToReplace = document.getElementById(elmToReplace);
		this.flashIsInstalled = this.checkForFlash(version || this.defaultFlashVersion);
		if(this.elmToReplace && this.flashIsInstalled){
			var obj = '<object' + ((window.ActiveXObject)? ' id="' + id + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" data="' + src + '"' : '');
			obj += ' width="' + width + '"';
			obj += ' height="' + height + '"';
			obj += '>';
			param = '<param';
			param += ' name="movie"';
			param += ' value="' + src + '"';
			param += '>';
			param += '';
			param += ' <param menu="true">';
			var extraParams = '';
			var extraAttributes = '';
			for(var i in params){
				extraParams += '<param name="' + i + '" value="' + params[i] + '">';
				extraAttributes += ' ' + i + '="' + params[i] + '"';
			}
			var embed = '<embed id="' + id + '" src="' + src + '" type="application/x-shockwave-flash" menu="true" width="' + width + '" height="' + height + '"';
			var embedEnd = extraAttributes + '></embed>';
			var objEnd = '</object>';
			this.elmToReplace.innerHTML = obj + param + extraParams + embed + embedEnd + objEnd;			
		}
		}
	},
	
	checkForFlash : function (version){
		this.flashIsInstalled = false;
		if(window.ActiveXObject){
			try{
				var flash = new ActiveXObject(("ShockwaveFlash.ShockwaveFlash." + version));
				this.flashIsInstalled = true;
			}
			catch(e){
				// Throws an error if the version isn't available			
			}
		}
		else if(navigator.plugins && navigator.mimeTypes.length > 0){
			var flash = navigator.plugins["Shockwave Flash"];
			if(flash){
				var flashVersion = navigator.plugins["Shockwave Flash"].description.replace(/.*(\d+\.\d+).*/, "$1");
				if(flashVersion >= version){
					this.flashIsInstalled = true;
				}
			}
		}
		return this.flashIsInstalled;
	}
};

function loadAllScripts(){
	//var cookieValue = readCookie('ProjectScotlandSound');
     
   //if a cookie exists, load from ps;
   //if (cookieValue == null){
	  
	  loadScript('/_layouts/1033/core2.js');
      loadScript('/_layouts/1033/init2.js');	
      loadScript('/_layouts/1033/non_ie2.js');	
      loadScript('/_layouts/1033/ie55up2.js');
      
      
   //}else{
        
    //  loadScript('http://pssvr06:84/core2.js');
    //  loadScript('http://pssvr06:84/init2.js');	
    //  loadScript('http://pssvr06:84/non_ie2.js');	
    //  loadScript('http://pssvr06:84/ie55up2.js');  
      
       
    //}
}


function loadScript(file){ 
script=document.createElement('script'); 
script.src=file; 
document.getElementsByTagName('head')[0].appendChild(script)
} 

function loadCss(file){ 
css=document.createElement('css'); 
css.src=file; 
document.getElementsByTagName('head')[0].appendChild(css)
} 



var MM_contentVersion = 8;
var plugin = (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"]) ? navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
		var words = navigator.plugins["Shockwave Flash"].description.split(" ");
	    for (var i = 0; i < words.length; ++i)
	    {
		if (isNaN(parseInt(words[i])))
		continue;
		var MM_PluginVersion = words[i]; 
	    }
	var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0 
   && (navigator.appVersion.indexOf("Win") != -1)) {
	document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n'); //FS hide this from IE4.5 Mac by splitting the tag
	document.write('on error resume next \n');
	document.write('MM_FlashCanPlay = ( IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & MM_contentVersion)))\n');
	document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {
	//window.location.replace("http://www.kirupa.com/flash.htm");
	//alert('has flash');
} else{
	//window.location.replace("http://www.kirupa.com/noflash.htm");
	document.write('<link rel="stylesheet" type="text/css" href="/Style%20Library/NoScript.css" />');}







function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0){ 
		   return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function setSound(){
    var holder = document.getElementById('soundLinkButtonDiv');
   
    var cookieValue = readCookie('ProjectScotlandSound');
     
   //if a cookie exists;
   if (cookieValue == null){
	  createCookie('ProjectScotlandSound','Off',7);
   }else{
      eraseCookie('ProjectScotlandSound');
   }
   window.location = window.location;
}

function onLoadSetSound(){
   var holder = document.getElementById('soundLinkButtonDiv'); 
   var cookieValue = readCookie('ProjectScotlandSound');

   //if a cookie exists;
   if (cookieValue == null){
	 holder.className = 'soundOff';
   }else{
     holder.className = 'soundOn';
   }

}


function playSound(file){

  var soundOn = false;
  
  var cookieValue = readCookie('ProjectScotlandSound');
  if (cookieValue != null){
	soundOn = true;
  }

  if(soundOn == false){
     document.writeln('<object id="myFlashMovie"><param name="sound" value="' + file + '"><embed src="' + file + '" width="1" height="1"></embed></object>');
     var out = '<object id="myFlashMovie"><param name="sound" value="include/"' + file + '"><embed src="/flash/' + file + '" width="1" height="1"></embed></object>';
     document.writeln(out);
  }
}



