/* This is the plugin for Text Children - http://plugins.learningjquery.com/textchildren/
It is included here and not seperate as it needs to appear above any normal jquery code. Vyre keeps placing the scripts in the wrong order. */
(function($){$.fn.textChildren=function(n,options){if(typeof n=='object'){options=n;n='all'}var opts=$.extend({},$.fn.textChildren.defaults,options||{});var output=opts.outputType=='string'?'':[];var contents='';this.each(function(index){var nodeIndex=n;var txtNodes=$.grep(this.childNodes,function(node){return(node.nodeType==3)});if(n=='first'){nodeIndex=0}else if(n=='last'){nodeIndex=txtNodes.length-1}else if(n<0){nodeIndex=txtNodes.length+n}if(nodeIndex>=txtNodes.length||nodeIndex<0){return}if(n==undefined||n=='all'){for(var i=0;i<txtNodes.length;i++){contents=opts.trim?$.trim(txtNodes[i].nodeValue):txtNodes[i].nodeValue;if(opts.outputType=='array'){(output.length&&contents=='')?output:output.push(contents)}else{output+=output==''?contents:opts.stringDelimiter+contents}}}else{contents=opts.trim?$.trim(txtNodes[nodeIndex].nodeValue):txtNodes[nodeIndex].nodeValue;if(opts.outputType=='array'){output.push(contents)}else{output+=output==''?contents:opts.stringDelimiter+contents}}});return output};$.fn.textChildren.defaults={outputType:'string',stringDelimiter:'',trim:true}})(jQuery);

// All functions must go inside the ready function




// DO NOT DELETE THIS SCRIPT - HYover pop up box with intro e.g form with i icon button e.g - /aatvideocompetition/aatvideocompetitionform
$(document).ready(function(){

$(".imgHoverhide").hover(function() {
    $(this).children("img").fadeTo(200, 0.25)
           .end().children(".hovertiphide").show();
}, function() {
    $(this).children("img").fadeTo(200, 1)
           .end().children(".hovertiphide").hide();
});
// ENDED

	
     /* Loops through each li on the page and applies 'link-list' to parent ul 
      * but not if the first child node of the li item is text, ie if a link exists 
      * as the first child it will get the class. Also doesn't apply it if the ul already has a class of menu 
      */
	
     $('#content ul li').each(function() {
          var item = $(this);
    
	  if (item.parent().attr('class') != "menu") {
	      if (!item.textChildren(0)) {
		  item.parent().addClass('link-list');	
	      }
          }
     });

     $('span.toggleAll input').click(function() {
        $('table.displayTable').css("display","none");
                
        if ($(this).val()=="Hide all")
            $(this).val('Show all');	    
	else
        {
	    $('table.displayTable').toggle(); 
	    $(this).val('Hide all');		
	}
     });

     //Fix for IE6 only. If there is a PDF in the article, it is getting rid of the parameter download=1
     jQuery.each(jQuery.browser, function(i, val) {
         
         if (i=="msie" && jQuery.browser.version.substr(0,3)=="6.0") {
             $("#article_main_2ndcolumns a[href*='&download=1']").each(function(index) {
                 hrefString = $(this).attr("href").replace('&download=1','');
                 $(this).attr("href",hrefString)
             });
         }   
     });


     $("#content a[href*='%20']").each(function() {

         $(this).attr('href', $(this).attr("href").replace(/%20/g," "));

     });

      
});

function getURL()
{
	var url = window.location.href;

	if (url=='http://www.accountingtechnician.co.uk/'||url=='http://www.accountingtechnician.co.uk') {
		url = 'http://www.accountingtechnician.co.uk/atonline/';
	}

	if (url=='http://www.aat.org.uk'||url=='http://www.aat.org.uk/'||url=='https://www.aat.org.uk'||url=='https://www.aat.org.uk/') {
		url = 'http://www.aat.org.uk/home/';
	}

	if (url=='http://intranet.aat.org.uk'||url=='http://intranet.aat.org.uk/') {
		url = 'http://intranet.aat.org.uk/intranet/home/';
	}
}

