//Cross browser hide

//Test to see if Javascript is enabled and if it is add the accessability stylesheet
if (document.getElementById && document.getElementsByTagName){			
	document.write("<link href=\"/display/accessibility.css\" type=\"text/css\" rel=\"stylesheet\">");
}


function FavouritesWindow(x, y) {
	var NewWindow = null;
	if (!NewWindow || NewWindow.closed) {
		NewWindow = window.open(x, y, 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, copyhistory=no, width=400, height=400');
	} else {
		NewWindow.focus();
	}
}

function FaveHelpWindow(x, y) {
	var NewWindow = null;
	if (!NewWindow || NewWindow.closed) {
		NewWindow = window.open(x, y, 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, copyhistory=no, width=400, height=400');
	} else {
		NewWindow.focus();
	}
}

// this is for signup help
function InfoWindow(x, y) {
	var NewWindow = null;
	if (!NewWindow || NewWindow.closed) {
		NewWindow = window.open(x, y, 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, copyhistory=no, width=500, height=300');
	} else {
		NewWindow.focus();
	}
}

// t+c window
function TermsWindow() {
	var NewWindow = null;
	if (!NewWindow || NewWindow.closed) {
		NewWindow = window.open("/library/pdf/terms_and_conditions.pdf", "terms", 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=450');
	} else {
		NewWindow.focus();
	}
}

// package window
function PackageWindow(strFilePath, intPackageID) {
	var NewWindow = null;
	if (!NewWindow || NewWindow.closed) {		
		NewWindow = window.open(strFilePath + intPackageID, "package", 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, copyhistory=no, width=500, height=400');
	} else {		
		NewWindow.navigate(strFilePath + intPackageID);
		NewWindow.focus();
	}
}

// channel window
function ChannelWindow(strFilePath, strChannelCode) {	
  var NewWindow = null;
	if (!NewWindow || NewWindow.closed) {		
		NewWindow = window.open(strFilePath + strChannelCode, "channel", 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, copyhistory=no, width=500, height=400');
	} else {		
		NewWindow.navigate(strFilePath + strChannelCode);
		NewWindow.focus();
	}
}

// faq window
function FaqWindow(strDocumentPath) {	
	var NewWindow = null;
	if (!NewWindow || NewWindow.closed) {		
		NewWindow = window.open(strDocumentPath, "faq", 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=yes, resizable=no, copyhistory=no, width=600, height=500');
	} else {		
		NewWindow.navigate(strDocumentPath);
		NewWindow.focus();
	}
}

// uchoose window
function UchooseWindow(strDocumentPath) {	
	var NewWindow = null;
	if (!NewWindow || NewWindow.closed) {		
		NewWindow = window.open(strDocumentPath, "uchoose", 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=no, copyhistory=no, width=590, height=380');
	} else {		
		NewWindow.navigate(strDocumentPath);
		NewWindow.focus();
	}
}

// what is digital movie window
function WhatIsWindow(strDocumentPath) {	
	var NewWindow = null;
	if (!NewWindow || NewWindow.closed) {		
		NewWindow = window.open(strDocumentPath, "WhatIsDigital", 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=no, copyhistory=no, width=640, height=440');
	} else {		
		NewWindow.navigate(strDocumentPath);
		NewWindow.focus();
	}
}

// Generic Demo window - to be used from now on, however not removing references to the functions above
function PopupDemoWindow(strTitle, strDocumentPath, intWidth, intHeight) {	
	var NewWindow = null;
	if (!NewWindow || NewWindow.closed) {		
		NewWindow = window.open(strDocumentPath, strTitle, 'menubar=no, toolbar=no, location=no, directories=no, status=no, scrollbars=no, resizable=no, copyhistory=no, width=' + intWidth + ', height=' + intHeight);
	} else {		
		NewWindow.navigate(strDocumentPath);
		NewWindow.focus();
	}
}

function go(obj) {
  s = obj.options[obj.selectedIndex].value;
  if (s !== '') {
		top.location.href = s;
	}
}

function swapImage(imgRef, imgSrc) {
	eval("document." + imgRef + ".src = '" + imgSrc + "'");
}

var n = document.layers?true:false;
var ie = document.all?true:false;
var div;

function hideLayer(ref) {
	killAll();
	if (n) {
		document.layers[ref].visibility = 'hidden';
	} else if (ie) {
		document.all[ref].style.visibility = 'hidden';
	}
}

//Cross browser show
function showLayer(ref) {
	killAll();
	if (n) {
		document.layers[ref].visibility = 'visible';
	} else if (ie) {
		document.all[ref].style.visibility = 'visible';
		div = ref;
	}
} 

function returnObjById( id ){
		var returnVar;
    if (document.getElementById) {
        returnVar = document.getElementById(id);
		} else if (document.all) {
        returnVar = document.all[id];
		} else if (document.layers) {
        returnVar = document.layers[id];
		}
    return returnVar;
}

function toggleLayer(whichLayer){
    var div = returnObjById(whichLayer).style;
    div.height = '138px';
    div.width = '760px';
}

function shrinkLayer(whichLayer){
    var div = returnObjById(whichLayer).style;
    div.height = '0px';
    div.width = '0px';
}

// Collapse panel accessability compliance script based on:
// Copyright 2006 | Thierry Koblentz - www.TJKDesign.com All Rights reserved
// TJK_ToggleDL() Version 1.5.4 report bugs or errors to thierry@tjkdesign.com

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            if (oldonload) {
                oldonload();
            }
            func();
        }
    }
}

function TJK_doToggleDL(x) {
	var zDD=document.getElementById('TJK_DL').getElementsByTagName('dd');
	var zDT=document.getElementById('TJK_DL').getElementsByTagName('dt');	
		zDD[x].className=(zDD[x].className=='hideDD')?'showDD':'hideDD';
		zDT[x].className=(zDT[x].className=='DTplus')?'DTminus':'DTplus';	
}

function TJK_ToggleDLopen(){//we open all of them
	var zDD=document.getElementById('TJK_DL').getElementsByTagName('dd');
	var zDT=document.getElementById('TJK_DL').getElementsByTagName('dt');	
	for(var i=0;i<zDT.length;i++) {
		zDD[i].className='showDD';
		zDT[i].className='DTminus';
	}
	return false;
}

function TJK_ToggleDLclose(){//we close all of them	
	var zDD=document.getElementById('TJK_DL').getElementsByTagName('dd');
	var zDT=document.getElementById('TJK_DL').getElementsByTagName('dt');	
	for(var i=0;i<zDT.length;i++) {
		zDD[i].className='hideDD';
		zDT[i].className='DTplus';
	}
	return false;	
}

function TJK_ToggleDL(){
if (document.getElementById && document.getElementsByTagName){			
	var zDT=document.getElementById('TJK_DL').getElementsByTagName('dt');
	var zDD=document.getElementById('TJK_DL').getElementsByTagName('dd');
	var ToggleON = document.getElementById('TJK_ToggleON');
	var ToggleOFF = document.getElementById('TJK_ToggleOFF');	
	if (ToggleON && ToggleOFF) {// Show All - Hide All "links"
		ToggleON.onclick = TJK_ToggleDLopen;
		ToggleON.title = "Show all answers";
		ToggleON.href = "#";		
		ToggleOFF.onclick = TJK_ToggleDLclose;	
		ToggleOFF.title = "Hide all answers";
		ToggleOFF.href = "#";		
	}
	for(var i=0;i<zDT.length;i++){
		var zContent = zDT[i].innerHTML;
		var zHref = "<a href='#' onclick=\"TJK_doToggleDL("+i+");return false\" title='Show/hide the answer'>";
		zDT[i].innerHTML = zHref + zContent + "</a>";
		zDD[i].className='hideDD';
		zDT[i].className='DTplus';
		}
	}
}

// End TJK_ToggleDL()
/*
Script: OptionChannelReveal
Author: Andy Badke
Description: This class allows a set of trigger objects to hide or show a set of associated objects.
In this case two arrays are passed in, one of objects and one of associate objects.
Each object is paired to its associate object in the order they appear in the array, and clicking the element will toggle
its state and toggle the display style of its associate.
*/
var OptionChannelReveal = new Class({
    Implements: [Options, Events],
    //options
    options: {
        //elements to attach click events to (the controller elements)
        elements: [],
        //elements to apply the change to (associate elements)
        associateElements: []
    },

    //init
    initialize: function(options) {
        //set options
        this.setOptions(options);
        //call the seetup method with the supplied elements
        this.setupElements(this.options.elements);
    },

    //sets up each object with a click event and handlers
    setupElements: function(objects) {
        //for each object
        $$(objects).each(function(el, i) {
            //add click event
            el.addEvent('click', function(e) {
                //stop any default click behaviour (in this case, stop the checkbox toggle)
                e.preventDefault();
                //toggle the element display
                el.toggle();
            });
            el.toggle = function() {
                if (el.hasClass('Hide')) {
                    //hide
                    el = el.toggleClass('Hide');
                    el.set('text', 'show channels');

                    this.options.associateElements[i].setStyle('display', 'none');
                } else {
                    //show
                    el = el.toggleClass('Hide');
                    el.set('text', 'hide channels');
                    this.options.associateElements[i].setStyle('display', 'block');
                }
            } .bind(this);
        }, this);
    }
});