<!--
//************ Start Default Commands ************
function getQuery(val){
  var querystring = location.search.substring(1,location.search.length);
  var o = "";
  var tSec = querystring.indexOf(val+"=");
  var tStr = querystring.substring( (tSec+(val.length+1)),querystring.length);
  
  if(tSec != -1){
    if(tStr.indexOf('&') != -1){
      o = tStr.substring(0,tStr.indexOf('&'));
    } else {
      o = tStr;
    }
  }
  return o;
}

function replaceSubstring(s,f,w){
  rtn = "";
  flg = 0;
  
  for(i = 0; i < s.length; i++){
    if(s.substr(i,f.length) == f){
      rtn += w;
      i += (f.length - 1);
    } else {
      rtn += s.charAt(i);
    }
  }
  return (rtn);
}

function urlencode(str) {
  str = escape(str);
  str = str.replace('+', '%2B');
  str = str.replace('%20', '+');
  str = str.replace('*', '%2A');
  str = str.replace('/', '%2F');
  str = str.replace('@', '%40');
  return str;
}

function testAlphaPassword(f,d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];
  var ele = doc.elements[f];
  var str = false;

  if(ele.value == ""){
    alert("Please enter a password");
  } else {
    if(/[^a-zA-z0-9]/i.test(ele.value)){
      alert("Sorry, your password may only contain letters and numbers");
    } else {
      str = true;
    }
  }
  return str;
}

function getCookie(Name){ 
  var search = Name + "=" 
  if(document.cookie.length > 0){
    offset = document.cookie.indexOf(search);
    if(offset != -1){
      offset += search.length;
      end = document.cookie.indexOf(";", offset);
      if(end == -1){ end = document.cookie.length; }
      return unescape(document.cookie.substring(offset, end)) ;
    }
  } 
} 

function setCookie(name, value) {
  var today = new Date(); 
  expires = new Date(); 
  expires.setTime(today.getTime() + 1000*60*60*24*1);
  document.cookie = name + "=" + value + ";path=/;expires=" + expires.toGMTString();
}

function goPage(u){
  location.href = u;
}

//************ End Default Commands ************
function updatePage(d){
  if(d == ""){ d = 0; }
  var doc = document.forms[d];
  doc.submit();
}

function reloadParent(){
  var pos = typeof window.pageYOffset != 'undefined' ?
	window.pageYOffset:document.documentElement &&
	document.documentElement.scrollTop ?
	document.documentElement.scrollTop: document.body.scrollTop?
	document.body.scrollTop:0;
  if(pos > 0){ window.scrollTo(0,location.hash); }
}

function loadAQIssue(t){
  location.href = t.options[t.selectedIndex].value + "#aqlink";
}

//************ Cufon ************ 
Cufon.replace('#pagestrap');


//************ jQuery ************ 
function imageSetup(){
  $('.pageimage620').each(function(){
    var mt = (($(this).children('span.image').height()-$(this).children('span.details').height())-9);
    $(this).children('span.details').css('top',mt + 'px');
    $(this).css('height',$(this).children('span.image').height()+'px');
    $(this).children('span.image').css('position','absolute');
  });
}

$(document).ready(function(){
  $('#page_footer ul li:last').css({'padding':'0','margin':'0','border':'0'})
  $('.panel dl').each(function(){ $(this).children('dt:last').css('border','0'); });
  $('.panel .inlimg').each(function(){ if($(this).children('div').height() < 55){ $(this).children('div').css('height','55px'); } });
  $('.twocol .inlimg').each(function(){ $(this).css('border','0'); });
  $('.wo_tabs a:first').css('margin-left','10px');
  $('.criticreviews li:last').css({'border':'0','margin':'0'});
  $('.entry_details p.border:last').css({'display':'none'});
  $('.related_doc:last').css({'border':'0'});

  $('span.title').each(function(){
    if($(this).children('a').hasClass('larger')){ $(this).css('margin-bottom','8px'); }
  });

  $('#buynow').click(function(){ $('#nap_options input').each(function(){ if($(this).attr('checked')){ location.href = $(this).val(); } }); });

  $('.pagepromos div.nap_advert').each(function(){
    $(this).css('margin-bottom','20px');
  });

  $('.pagepromos div.panel div.inlimg').each(function(){
    $(this).parent('div').css('border-bottom','0');
    $(this).css('border-bottom','0');
  });

  $('.panel .inlimg').click(function(){
    if($(this).find('a').attr('onclick')){
      window.open($(this).find('a').attr('href'));
    } else {
      window.location=$(this).find('a').attr('href'); return false;
    }
  });

  $('#nap_panel .hero').click(function(){
    if($(this).find('a').attr('onclick')){
      window.open($(this).find('a').attr('href'));
    } else {
      window.location=$(this).find('a').attr('href'); return false;
    }
  });

  $('.nap_advert').click(function(){
    if($(this).find('a').attr('onclick')){
      window.open($(this).find('a').attr('href'));
    } else {
      window.location=$(this).find('a').attr('href'); return false;
    }
  });

  $('.homesearch a').click(function(){
    if($('#searchquery').val() != ""){
      location.href = "/whatson/" + replaceSubstring(escape($('#searchquery').val()),'%20','+');
    } else {
      $('#search_error').fadeIn().delay(2000).fadeOut('fast');
    }
  });

  $('.homesearch #searchquery').keydown(function(event){
    if(event.keyCode == '13'){
      if($('#searchquery').val() != ""){
        location.href = "/whatson/" + replaceSubstring(escape($('#searchquery').val()),'%20','+');
      } else {
        $('#search_error').fadeIn().delay(2000).fadeOut('fast');
      }
    }
  });

});

//-->
