var movieName = "soundfx";
var isFlashInstalled=false;
noautoinstall = "";
if(navigator.appName == "Microsoft Internet Explorer" && 
                (navigator.appVersion.indexOf("Mac") != -1 || 
                 navigator.appVersion.indexOf("3.1") != -1)){
                        noautoinstall = "true";
        }

if (navigator.appName == "Microsoft Internet Explorer" && noautoinstall != "true")
        {
                isFlashInstalled=true;
        }
else if(navigator.plugins)
        {
                if(navigator.plugins["Shockwave Flash"] || navigator.plugins["Shockwave Flash 2.0"])
                {
                       isFlashInstalled=true;
                }
          }
if(isFlashInstalled){
        if(document.getElementById){
        //alert('hiding image for flash replacement');
        document.writeln('<style type="text/css">div#flashcontent {        background-image: none!important;}</style>');
        }
}
 function is_iemac(){
        var SniffVer=navigator.appVersion;
        SniffVer=SniffVer.substring(0,4);
        var SniffClient=navigator.appName;
        var SniffOS=navigator.platform;
        if(SniffOS=='MacPPC' && SniffClient=='Microsoft Internet Explorer'){
                        return true;
                        }
                        else{return false;}
						
}
                   
function thisMovie(movieName) {
  // IE and Netscape refer to the movie object differently.
  // This function returns the appropriate syntax depending on the browser.
  if (navigator.appName.indexOf ("Microsoft") !=-1) {    return window[movieName]  }        else {    return document[movieName]  }
}
// Checks if movie is completely loaded.
// Returns true if yes, false if no.
function movieIsLoaded (theMovie) {
  if (typeof(theMovie) != "undefined") {    return theMovie.PercentLoaded() == 100;  } else {    return false;
  }
}
function playmovie() {
  if (movieIsLoaded(thisMovie(movieName))) {    thisMovie(movieName).Play();  }
}
function stopmovie() {
  if (movieIsLoaded(thisMovie(movieName))) {    thisMovie(movieName).StopPlay();  }
}
function goframe(theFrame) {
       //alert(theFrame);
  		if (movieIsLoaded(thisMovie(movieName))) {  thisMovie(movieName).GotoFrame(theFrame);  }
}
function golabel() {  if (movieIsLoaded(thisMovie(movieName))) {   thisMovie(movieName).TGotoLabel("_level0/","redframe");  }
}


function imgPopup(url,alt){
        var openIpix='';
        var closeIpix='';
        var isIpix=false;
        urlExtension=url.split(".");
        if(urlExtension[urlExtension.length-1]=='ipx'){isIpix=true;}
        //else{alert('not an ipix, must be an image');}
                                        var imgPopup=window.open('','imgPopup','height=50,width=50,toolbar=no,scrollbars=no,resizable=yes,menubar=no,status=no,directories=no,location=no,50,50');
                                        imgPopup.document.open();
                                        imgPopup.document.writeln('<html><head><title>image</title> \n <style type="text/css"> \n a{color:#3f3479;} p#caption{background-color:#eeeeee;text-align: left;padding-left: 10px;padding-right: 10px;}  \n body {font-family: Tahoma, Arial, Helvetica, sans-serif;text-align: center;} \n p {font-size: 70%;margin-top: 0px;padding-top: 0.5em;padding-bottom: 1em;} \n img {display: block; margin-right: auto; margin-left: auto;} \n  p.close {text-align: center; margin-bottom: 0px;        width: 9em;        float: right;        color: #FFFFFF;           padding: 3px;        font-weight: normal;}  \n </style> \n </head> \n <body>');
                                                                               imgPopup.document.writeln('<img src="' + url + '" alt="' + alt + '" id="lrgimage" />');
                                                                               imgPopup.document.writeln(' \n<p class="close"><a href="javascript:window.close();">Close Window</a></p> \n </body> \n </html>');
                                                                               imgPopup.document.title=alt;
                                                                               var bigImage=imgPopup.document.getElementById('lrgimage');
                                        var captiontxt=imgPopup.document.getElementById('caption');
                                                                                //alert(bigImage.width);
                                        //captiontxt.style.color='#333333';
                                        //captiontxt.style.fontsize='70%';
                                        //1st resize for shitty explorer
                                                var newwidth=bigImage.width+60;
                                                if(!newwidth){newwidth=490;}
                                                var newheight=imgPopup.document.body.scrollHeight+40;
                                                imgPopup.resizeTo(newwidth,newheight);
                                                imgPopup.window.focus;
                                                
                                        bigImage.onload = function ()
                                        //for firefox
                                        {
                                                newwidth=bigImage.width+40;
                                                newheight=imgPopup.document.body.scrollHeight+60;
                                                imgPopup.resizeTo(newwidth,newheight);
                                                imgPopup.window.focus;
                                        }
                                                                                window.onload = function ()
                                        //for firefox
                                        {
                                                newwidth=bigImage.width+40;
                                                newheight=imgPopup.document.body.scrollHeight+60;
                                                imgPopup.resizeTo(newwidth,newheight);
                                                imgPopup.window.focus;
                                        }
                                                                                imgPopup.onblur=imgPopup.window.focus;
}

function docPopup(url){
                                                window.open(url,'popup');
}

/*function popupLinks(){
if(!document.getElementById)return false;
var aLinks= document.getElementsByTagName('a') || document.getElementsByTagName('span');
//alert('running script');
for (var i=0;i<aLinks.length;i++) {
        if (aLinks[i].className == 'popup' || 'linkUrl')
                        {
                                aLinks[i].onclick = function ()
                                {
                                        //alert(linktype);]
                                        //
										//alert('clicked');
										var href= this.getAttribute('href');
                                        var linktype=href;
                                        var linktype_array=linktype.split(".");
                                        var linkex=linktype_array[linktype_array.length-1];
                                                                                linkex=linkex.toLowerCase();
                                        //if(this.protocol=="file:"){
                                        if(linkex=='jpg' || linkex=='gif' || linkex=='ipx'){
                                                imgPopup(this.getAttribute('href'),this.getAttribute('title') );}
                                        else{
											alert(this.href);
											docPopup(
													 this.href);
											}
                                return false;
                                }
                                //return false;
                        }
                        aLinks[i].onkeypress = aLinks[i].onclick;
                }
}
*/
function pdfme(){
if (!document.getElementsByTagName) return false; 
var links = document.getElementsByTagName("a");
for (var eleLink=0; eleLink < links.length; eleLink ++) {
	//alert(links.length);
	if (links[eleLink].className == 'popup')
//if (links[eleLink].href.indexOf('.pdf') !== -1) 
{

	//alert(links[eleLink].href);
	
	links[eleLink].onclick = function(){
		var links = this;
		var url=this.value;
		//alert(links);
		//window.open(url,'resizable,scrollbars'); 
		}
		
	}  
}
}

function toggleAdvancedOptions(){
	x=document.getElementById('advsearch');
	var newcontrol=document.getElementById('newcontrol');
	if (x.style.display=='none')
	{
		x.style.display='block';
		newcontrol.innerHTML='<a href="javascript:toggleAdvancedOptions();" >more options</a>  - ';
		}
	else{x.style.display='none';
	newcontrol.innerHTML='<a href="javascript:toggleAdvancedOptions();" >more options</a> + ';}	
}







function hideAdvancedSearch(){
	if (!document.getElementById('Diary')) return false;
	var x=document.getElementById('advsearch');
	var newcontrol=document.getElementById('newcontrol');
	newcontrol.innerHTML='<a href="javascript:toggleAdvancedOptions();" >more options</a> + ';
	x.style.display='none';
	//alert(x.innerHTML);   
}

function setActiveStyleSheet(title){ 
if (is_iemac()){
        return false;
}
 var i, a, main;
  if (title) {
    for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
      if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title') ) {
       if(a.getAttribute('title')!='printstyle'){
                  // alert(a.getAttribute('title'));
                           a.disabled = true;
                   }
        if(a.getAttribute('title') == title && a.getAttribute('title')!='printstyle' ) a.disabled = false;
      }
    }
  }
  //hideDiv('loadingcontent');
//ReDraw();
}

function getActiveStyleSheet() {
    var i, a;
    for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
      if(a.getAttribute('rel').indexOf('style') != -1 && a.getAttribute('title') && !a.disabled ) return a.getAttribute('title');
    }
    return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName('link')[i]); i++) {
    if(a.getAttribute('rel').indexOf('style') != -1
       && a.getAttribute('rel').indexOf('alt') == -1
       && a.getAttribute('title')
       )
       return a.getAttribute('title');
  }
  return null;
//ReDraw();
}

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 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);
}
//comment in to activate
        //window.onload = function(e) {
        //var cookie = readCookie('second-themeName');
          //var title = cookie ? cookie : getPreferredStyleSheet();
          //setActiveStyleSheet(title);
//}

window.onunload = function(e) {
        var title = getActiveStyleSheet();
          createCookie('second-themeName', title, 365);
}

function changeTxtSize(direction){
                //alert('calling function correctly');
                var textIncrement=10;//percentage by which font size is increased
                if(document.body.style.fontSize==''){document.body.style.fontSize='100%';}
                if(direction=='dec'){textIncrement=-textIncrement;}
                //alert(textIncrement);
                  newFs=parseInt(document.body.style.fontSize)+textIncrement;
                createCookie('preferedFontSize', newFs,365);
                document.body.style.fontSize=newFs+'%';
                //alert(document.body.style.fontSize);
                
}


function swapTextTool(){
        
if(document.getElementById('txtcontrols') && !is_iemac()){
        var TC = document.getElementById('txtcontrols');
        //a.innerHTML="<a href=\"textsize.htm\">increase text size</a> | <a href=\"textsize.htm\">decrease text size</a>";
		
		var swappedtext='<h3>Text controls</h3>';
		//if(document.location.pathname=="/view.aspx"){
	 	swappedtext=swappedtext+' <img src="/Scripts/artsminds/textcontrols.gif" border="0" usemap="#Map" />';
		//}else{
		//swappedtext=swappedtext+' <img src="/Scripts/artsminds/textcontrols.gif" width="147" height="39" border="0" usemap="#Map" />';
		//}
      	swappedtext=swappedtext+'<map name="Map" id="Map">';
        swappedtext=swappedtext+'<area shape="rect" coords="9,3,26,20" href="javascript:changeTxtSize(\'inc\');" alt="click here to make the text larger" />';
        swappedtext=swappedtext+'<area shape="rect" coords="31,3,48,20" href="javascript:changeTxtSize(\'dec\');" alt="click here to make the text smaller" />';
        swappedtext=swappedtext+'<area shape="rect" coords="69,3,79,20" href="javascript:setActiveStyleSheet(\'high contrast\');"alt="click here to use the inverted high contrast style sheet" />';
        swappedtext=swappedtext+'<area shape="rect" coords="84,3,101,20" href="javascript:setActiveStyleSheet(\'high contrast inverted\');" alt="click here to use the high contrast style sheet" />';
      	swappedtext=swappedtext+'</map>';
	  	swappedtext=swappedtext+'<p><a href="javascript:setActiveStyleSheet(\'standard stylesheet\');setDefaultFontSize();" title="user normal text size and colours" >use normal text</a></p>';


        TC.innerHTML=swappedtext;
        }
}
 
function getFontSize(){
           var pFS = readCookie('preferedFontSize');
                if(pFS)        {document.body.style.fontSize=pFS +'%';        }
 }
 function setDefaultFontSize(){
                 createCookie('preferedFontSize','',-365);
                {document.body.style.fontSize='100%';        }
 }
 function getstyle(){
         var pSS = readCookie('second-themeName');
         setActiveStyleSheet(pSS);
 }
 function swapflash(movieName,container,width,height,flashid){
		var newCode='';
        var flashCode='';
        var flashContainer='';
        var activestyle=getActiveStyleSheet();
		flashContainer=document.getElementById(container);
        //if(isFlashInstalled&&activestyle=="regular"){
if(isFlashInstalled && 1==1 ){

			//if(document.location.pathname=="/view.aspx"){movieName="flash/"+movieName;}

			 //  else{movieName="../../../../flash/"+movieName;}

                        

                        //customisation

                        //flashContainer.style.position="relative";  

						flashContainer.style.padding="0"
						flashContainer.style.visibility="hidden";
                        			

						flashCode= "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " ;
                        flashCode=flashCode + "codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" ";
                        flashCode=flashCode + "width=\"" + width + "\" height=\""+height+"\" >\n ";
                        flashCode=flashCode + "  <param name=\"movie\" value=\" " + movieName + " \">\n";
						flashCode=flashCode+"<PARAM NAME=bgcolor VALUE=#3AAFA7> ";
                        flashCode=flashCode + "  <embed src=\""+ movieName + "\" bgcolor=#3AAFA7  quality=\"high\" wmode=transparent pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+width+"\" height=\""+height+"\">\n ";
                        flashCode=flashCode + "  </embed>\n";
                        flashCode=flashCode + "</object>\n";

						

                        //newCode=flashCode+flashContainer.innerHTML;

						newCode=flashCode;

						//alert(flashCode);

                       	flashContainer.innerHTML=newCode;

						flashContainer.style.visibility="visible";

						//alert(flashContainer.innerHTML);

                        }else{							
						flashContainer.style.backgroundImage="url(/flash/sfccareers/flash_006.jpg)";
						flashContainer.style.width=width+"px";
						flashContainer.style.height=height+"px";
						}
}
function trans(frame,theUrl){
        if(qPress!=0){return;}
        qPress++;
        //var theUrl=this.getAttribute('href');
        //alert(theUrl);
       
        go(frame);
                //hide flash
                document.getElementById('flashcontent').style.visibility='hidden';
                
				//alert(getActiveStyleSheet());
			if(getActiveStyleSheet()=='standard stylesheet'){
				divshow('loadingcontent');
				//alert('running timeout');
           		setTimeout('msgpopup("'+theUrl+'")',2000);
		  }else{
			  //alert('straight there');
			  document.location=theUrl;}
}

var qPress=0;
 
 function preparelinks(){
         if(!document.getElementById)return false;
		
         //array for sounds//
         var snds = new Array (4);
         snds['menu_AboutUs'] =10;
         snds['menu_Gallery'] =20;
         snds['menu_News']=30;
         snds['menu_Publications']=40;
         snds['menu_Links']=50;
         //
         
        //a=document.getElementById(theParent);
        var aLinks=document.getElementsByTagName('a');
         
        for (var i=0;i<aLinks.length;i++) {
                aLinks[i].onmouseover = function ()
                                {
                                theclass=this.parentNode.getAttribute('class');
								if(!theclass){theclass=this.parentNode.getAttribute('className');}
                                if(snds[theclass]&&this.parentNode.nodeName=='LI')
                               	 {
									 //alert(snds[theclass]);
									 //alert(snds[theclass]);
									 goframe(snds[theclass]);
									//alert('send flash audio clip to frame'+snds[theclass]);
									//trans(snds[theclass],thedestination);
									} 

                               //return false;
                     }
                }
 }
function msgpopup(destination){
//document.location=document.location;
document.location=destination;
qPress=0;
}
function setmainheight(){
	if(!document.getElementById('maincontent')|!document.getElementById('navigation')|!document.getElementById('secondary'))return false;
var mdiv=document.getElementById('maincontent');
var ndiv=document.getElementById('navigation');
var sdiv=document.getElementById('secondary');
//alert(ndiv.offsetHeight);
//alert(mdiv.offsetHeight);
//alert(sdiv.offsetHeight);ndiv.style.display!='none' &&sdiv.style.display!='none';)

if (sdiv.offsetHeight>mdiv.offsetHeight && sdiv.style.display!='none'){		
		mdiv.style.height=sdiv.offsetHeight+"px";
}
if (ndiv.offsetHeight>mdiv.offsetHeight && ndiv.style.display!='none'){
		mdiv.style.height=ndiv.offsetHeight+"px";
}

	
}

function loadfunctions(){
	if((document.parent)||document.getElementById('bblitebar'))return false;
	//popupLinks();
	hideAdvancedSearch();
	preparelinks();
	setmainheight();
	fixselects();
pdfme();
	//getFontSize();
    //swapTextTool();
	//getstyle();
	if(document.getElementById('entrypage')){
	swapflash("/flash/sfccareers/slideshow.swf",'animation',400,200,'flashmovie')
	}
}

function fixselects(){
	//alert(navigator.appName);
	/*var browname= navigator.appName;
	if(browname == 'Netscape'){
	return false;	
	}*/
	var selects=document.getElementsByTagName('select');
	for(var i=0;i<selects.length;i++){
		var dmr;
		var smallWidth=selects[i].clientWidth;
		selects[i].style.visibility="hidden";		
		selects[i].style.width="150";
		var bigWidth=selects[i].clientWidth;
		selects[i].style.width=smallWidth;
		selects[i].style.visibility='visible';		
		if(selects[i].style.display==null){selects[i].style.display='static';}
		var defaultpos=selects[i].style.position;		
		if(selects[i].style.marginRight==null){dmr=0;}else{dmr=selects[i].style.marginRight;}
		
		if(bigWidth>smallWidth){	
		var theOptions=selects[i].getElementsByTagName('option');		
			selects[i].onmouseover=function(){this.style.width=bigWidth;this.style.marginRight="-"+(bigWidth-smallWidth);
											if(this.style.position!="absolute"){this.style.position="relative";}}
			selects[i].onmouseout=function(){this.style.width=smallWidth;this.style.position=defaultpos;this.style.marginRight=dmr;}
			selects[i].onclick=function(){this.onmouseout=function(){}}			
			selects[i].onblur=function(){this.style.width=smallWidth;this.style.position=defaultpos;this.style.marginRight=dmr;this.onmouseout=function(){this.style.width=smallWidth;this.style.position=defaultpos;this.style.marginRight=dmr;}}
			selects[i].onchange=function(){this.style.width=smallWidth;this.style.position=defaultpos;this.style.marginRight=dmr;	this.onmouseout=function(){this.style.width=smallWidth;this.style.position=defaultpos;this.style.marginRight=dmr;}}
		}}}


window.onload=loadfunctions;


