function openSubscribe() {
subscribe =  window.open('http://www.ecm7.com/cm/public/164/form.clsp?formid=1420','subscribe','width=600,height=450,status=yes,resizable=yes,scrollbars=yes');
subscribe.focus();
}


/* START RESIZE TEXT SCRIPT */


function resizeUp() {
	if(!document.getElementById('main2').style.fontSize){
		document.getElementById('main2').style.fontSize = '110%';
	} else {
		var str_fontsize = document.getElementById('main2').style.fontSize;
		var num_fontsize = str_fontsize.substring(0,str_fontsize.length-1);
		var num_newsize = num_fontsize * 1.1;
		document.getElementById('main2').style.fontSize = num_newsize + '%';
	}
}

function docWindow(url) {
var newWindow=window.open(url,'docWindow','height=900,width=550,toolbars=0,scrollbars=1,resizable=1');
}

function resizeZero() {
	document.getElementById('main2').style.fontSize = '100%';
}

function resizeDown() {
	if(!document.getElementById('main2').style.fontSize){
		document.getElementById('main2').style.fontSize = '90%';
	} else {
		var str_fontsize = document.getElementById('main2').style.fontSize;
		var num_fontsize = str_fontsize.substring(0,str_fontsize.length-1);
		var num_newsize = num_fontsize * 0.9;
		document.getElementById('main2').style.fontSize = num_newsize + '%';
	}
}

/* /END RESIZE TEXT SCRIPT */





/* START MAIL PAGE SCRIPT */

function mailpage()
{
  mail_str = "mailto:?subject= " + escape(document.title);
  mail_str += "&body=  You may be interested in the following page on the AWU National website. " + escape(location.href);
  mail_str += " %0D%0A(Please click on the link if your email software allows otherwise copy and paste the whole link into your web browser to view the page)";
document.getElementById('snHeading').innerHTML = 'Share This Article <span  style="display: none;">' + mail_str + '</span>';
  location.href = mail_str;
}

// Execute function
  function Go(){return}

/* /END MAIL PAGE SCRIPT */




/* START BRANCHES IMAGEMAP ROLLOVERS */

Image1 = new Image(160,130)
Image1.src = "/atwone/static/tas.gif"

Image2 = new Image(160,130)
Image2.src = "/atwone/static/vic.gif"

Image4 = new Image(160,130)
Image4.src = "/atwone/static/nsw.gif"

Image5 = new Image(160,130)
Image5.src = "/atwone/static/qld.gif"

Image6 = new Image(160,130)
Image6.src = "/atwone/static/sa.gif"

Image8 = new Image(160,130)
Image8.src = "/atwone/static/wa.gif"

Image9 = new Image(160,130)
Image9.src = "/atwone/static/map_branch.gif"


function tas() {
document.emp.src = Image1.src; return true;
}

function vic() {
document.emp.src = Image2.src; return true;
}

function nsw() {
document.emp.src = Image4.src; return true;
}

function qld() {
document.emp.src = Image5.src; return true;
}

function sa() {
document.emp.src = Image6.src; return true;
}

function wa() {
document.emp.src = Image8.src; return true;
}

function original() {
document.emp.src = Image9.src; return true;
}


/* /END BRANCHES IMAGEMAP ROLLOVERS */



/* START SHOW ICONS SCRIPT */

function showIcons() {
	var icons = document.getElementsByTagName('A');
	for(i=0; i<icons.length; i++) {
		if(icons[i].className=='noscript'){
			icons[i].className = 'scriptAvailable';
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", showIcons);
if (window.addEventListener) window.addEventListener( "load", showIcons, false );


/* /END SHOW ICONS SCRIPT */



/* START SHOW FLASH VIDEO */

function showVideoOld(id) {
var aVideo = new SWFObject("/atwone/flv/flvplayer.swf","single","320","240","7"); 
aVideo.addParam("allowfullscreen","true");
aVideo.addVariable("file","/atwone/flv/"+id+".flv");
aVideo.addVariable("autostart",true);
aVideo.write("playerPanel");
}

// Flowplayer configuration (less buttons and wicked background color) 
var playerConfig = { 
   /*controlBarBackgroundColor: '0x99cddc', */
   initialScale:'scale', 
   showMenu:false, 
   showVolumeSlider:true, 
   showMuteVolumeButton:false, 
   showFullScreenButton:true, 
   controlBarGloss:'high' 
} 
  
var flowplayer = null;  


function setUpVideoPlayer() { 

   // variable that holds the player API. it is initially null 
    
   /************* THE PLAYLIST ***************/ 





   // loop all links within DIV#playlist and customize their onClick event  
   var links = document.getElementById("playlist").getElementsByTagName("a");  
    
   for (var i = 0; i < links.length; i++) { 
       /* Special case if an mp3 
             1) Remove the 'flv' extension
             2) Change the url from /atwone/flv/file.mp3 to /atwone/pod/file.mp3
          */  
          var url = links[i].getAttribute("href");
         var extention = url.substr(url.length -3);      
         if ("mp3.flv" == url.substr(url.length - "mp3.flv".length)){
               url = url.substr(0, url.length - ".flv".length);
               url = "/atwone/pod" + url.substr(url.lastIndexOf('/'));
               links[i].setAttribute("href", url);
         }

      links[i].onclick = function() {  
         var href = this.getAttribute("href"); 
          
        if ("mp3" == href .substr(href .length - "mp3".length)){
               var image = this.getAttribute("name");   /* Thumbnail location is stored in the name */
               playerConfig.playList = [ { url: href , overlay: image}] ;
                playerConfig.videoFile = null ;  
        }
        else{
                  playerConfig.videoFile = href ;
        }
        
         if (flowplayer == null) { 
            flowplayer = flashembed("player",  
               {src:"/atwone/static/FlowPlayerDark.swf", bgcolor:'#6F7485'},  
               {config: playerConfig} 
            );  
             
         } else {     
            flowplayer.setConfig(playerConfig);  
         } 
         // disable link's default behaviour 
         return false;  
      }      
   } 
   // when clicks on the player it triggers our first playlist entry 
   document.getElementById("player").onclick = function()  { 
      links[0].onclick(); 
   } 
    /*  
        If you want your video to start when your  
        page loads then uncomment next line  
    */    
     document.getElementById("player").onclick(); 
}

/* Called when page loads*/
function playFirstMediaFile(){
    
    /* Automatically play media file if user hasn't already selected one before the page loaded */
   if (!flowplayer){
         var playlist = document.getElementById("playlist");
         if (playlist){
              var links = playlist.getElementsByTagName("a");
              if (links && links.length >= 1){
                   document.getElementById("player").onclick = function()  { 
                        links[0].onclick(); 
                   } 
                   /*  
                    If you want your video to start when your  
                    page loads then uncomment next line  
                    */    
                    document.getElementById("player").onclick(); 
              }
         }
   }

}

function playMedia(link){
        var href = link.getAttribute("href"); 
      
        var splashImage = "";
        if (getFileExtension(href) == "mp3"){
               splashImage = link.getAttribute("thumb");   /* Thumbnail location is stored in the name */            
        }
        
        embedFlashVideo("player", href, "", splashImage, 305, 255, true);
          
         // disable link's default behaviour 
         return false;  
}



/* /END SHOW FLASH VIDEO */


function newsQuery(cat,yr,cnt) {
  document.getElementById('newsContent').innerHTML='<img src="/atwone/static/ajaxWheel.gif" width="16" height="16" align="top">';
  var params = new Hash();
  params.set('category', cat);
  params.set('year', yr);
  params.set('cnt', cnt);

  new Ajax.Request('/atwone/static/news_query.cgi', {
  method: 'post',
  parameters: params,
  onSuccess: function(response) {
        if (response.status == 200 && response.statusText == 'OK') {
         document.getElementById('newsContent').innerHTML=response.responseText;
        if (cat!='') {
         document.getElementById('breadCrumbTitle').innerHTML='News » '+cat;
        } else {
         document.getElementById('breadCrumbTitle').innerHTML='News » '+yr;
        }
        } else {
         document.getElementById('newsContent').innerHTML=response.responseText;
        }
  },
  onFailure: function(response) {
         document.getElementById('newsContent').innerHTML=response.responseText;
  },
  onComplete: function(response) {
         document.getElementById('newsContent').innerHTML=response.responseText;
  }
});

}


function eventsQuery(yr,reg,ind,cnt) {
  document.getElementById('eventsContent').innerHTML='<img src="/atwone/static/ajaxWheel.gif" width="16" height="16" align="top">';
  var params = new Hash();
  params.set('year', yr);
  params.set('region', reg);
  params.set('industry', ind);

  new Ajax.Request('/atwone/static/events_query.cgi', {
  method: 'post',
  parameters: params,
  onSuccess: function(response) {
        if (response.status == 200 && response.statusText == 'OK') {
         document.getElementById('eventsontent').innerHTML=response.responseText;
        if (yr!='') {
         document.getElementById('breadCrumbTitle').innerHTML='Events » '+yr;
        } else if (reg!='') {
         document.getElementById('breadCrumbTitle').innerHTML='Events »  '+reg;
        } else {
         document.getElementById('breadCrumbTitle').innerHTML='Events » '+ind;
	}
        } else {
         document.getElementById('eventsContent').innerHTML=response.responseText;
        }
  },
  onFailure: function(response) {
         document.getElementById('eventsContent').innerHTML=response.responseText;
  },
  onComplete: function(response) {
         document.getElementById('eventsContent').innerHTML=response.responseText;
  }
});

}

function speechesQuery(yr) {
  document.getElementById('speechesContent').innerHTML='<img src="/atwone/static/ajaxWheel.gif" width="16" height="16" align="top">';
  var params = new Hash();
  params.set('year', yr);

  new Ajax.Request('/atwone/static/speeches_query.cgi', {
  method: 'post',
  parameters: params,
  onSuccess: function(response) {
        if (response.status == 200 && response.statusText == 'OK') {
         document.getElementById('speechesContent').innerHTML=response.responseText;
        if (cat!='') {
         document.getElementById('breadCrumbTitle').innerHTML='News » '+cat;
        } else {
         document.getElementById('breadCrumbTitle').innerHTML='News » '+yr;
        }
        } else {
         document.getElementById('speechesContent').innerHTML=response.responseText;
        }
  },
  onFailure: function(response) {
         document.getElementById('speechesContent').innerHTML=response.responseText;
  },
  onComplete: function(response) {
         document.getElementById('speechesContent').innerHTML=response.responseText;
  }
});

}


function highlightTab(pageName, complete) {
  var menu = document.getElementById("menu");
  var items = menu.getElementsByTagName("a");
  for (var i =0; i < items.length; i++) { 
    var a = items[i];
    var href = a.href;
        if (href.lastIndexOf(pageName) == (href.length - pageName.length)) {
          a.className = "selected";
        }
   }
}

function highlightTabFromGetParam() {
    var qmarkPos = window.location.href.lastIndexOf("?");
    if (qmarkPos == -1) return;
    var param = window.location.href.slice(qmarkPos);
    highlightTab(param);
}

function getFileExtension(file){
        var dotPos = -1;
        if (-1 != (dotPos = file.lastIndexOf("."))){
            return file.substring(dotPos + 1); 
        }
        return "";
    }

/*
  In order to play uploaded Flash files (i.e. Flash videos that haven't been converted from mpef, mov etc.) you need 
  to make a few changes to the way flashembed is used (as well as updating Flow Player to the latest version).
  1) Remove 'videoFile' and 'autoPlay' attributes as they are ignored.
  2) Specify the video in a playlist
  
  ffmpeg can not create a 'splash' image for an uploaded Flash file (it just creates an image 0 bytes in size). This causes
  a problem as flowplayer displayes an error message. So, as a workaround, we will let the user specify a thumbnail 
  which can be used as the splash image. 
 */ 
 function embedFlashVideo(divLocation, mediaFile, splashImage, thumbnail, width, height, autoplay, thumbnailDir){
    /* Initialise variables if not set */
    if (!width){
        width = 320;
    }
    if (!height){
        height = 240;
    }
    if (autoplay == undefined){
        autoplay = true;
    }
    if (!splashImage){
        splashImage = "";
    }
    if (!thumbnail){
        thumbnail = "";
    }
    if (!thumbnailDir){
          thumbnailDir = "/pics_orig/";
    }
        
    var pl = [];    //Create an array to store the playlist details
    var i = 0;
    
    var isAudio = getFileExtension(mediaFile) == "mp3";
    var isVideo = !isVideo;
    
    /*
      Display a splash image if an image is available and either
        1) file is audio, or
        2) file is video and autoplay is set to false (i.e. show 'splash' image)        
     */    
    /*
     Playlist object will end up looking like this:     
     playlist: ['spash_image.jpg', {url: movie.mpg.flv, autoplay: true/false}]
    */
    
     if (thumbnail != "" || splashImage != ""){
        if (isAudio || (isVideo && !autoplay)){
             
            /* 
                Don't display the image if using an uploaded flash file and no thumnail has been set. Using the
                default corrupted image created by ffmpeg causes an error so, in this case, we're better off not using an image/
             */
            if (!(mediaFile.lastIndexOf(".flv.flv") != -1 && thumbnail == "")){
		if(document.domain!='vic.awu.net.au') {
                                pl[i] = thumbnail != "" ? thumbnailDir + thumbnail : splashImage;      //thumbnail takes precedence
                } else {
                		pl[i] = splashImage;
                }
                i++;
            }
        }       
     }
     
    
    pl[i] = new Object;
    pl[i].url = mediaFile;
    pl[i].autoPlay = autoplay;
    
    flashembed(divLocation, 
        { src:"/atwone/static/flowplayer-3.0.2.swf", width:width, height:height, bgcolor:'#ffffff' }, 
        {config: 
            { playlist: pl,
              initialScale: 'scale', useNativeFullScreen: true,showMenu : false,showFullScreenButton : true,loop : false }
        } 
    );
 }

