//av scripts

function av_selfCentred(){
var width, height, w, h, x, y;
width = screen.availWidth;
height = screen.availHeight;
w = 1024;
h = 768;
if (width<1023) {
w=screen.availWidth;
}
if (height<767) {
h=screen.availHeight;
}
x = (screen.availWidth - w)/2;
y = (screen.availHeight - h)/2;
self.resizeTo(w,h);
self.moveTo(x,y);
} 

function av_linksafe(css,name,domain,linktext) {
document.write('<a class=\"' + css + '\" href=\"mailto:' + name + '@' + domain + '\">');
document.write(linktext + '</a>');
}

function av_pop(w,h,url) { 
x = (screen.availWidth - w)/2;
y = (screen.availHeight - h)/2;

window.open(url, '', 'height=' + h + ',width=' + w + ',scrollbars=0,resizable=1,menubar=0,toolbar=0,status=0,location=0,directories=0,left=' + x + ',top=' + y);
}

//ala style switch
function setCSS(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getCSS() {
  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 getPrefCSS() {
  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;
}

function checkWindow() {
  var w=0, h=0;
  // thanks to Mark Wilton Jones
  if( typeof( window.innerWidth ) == 'number' ) {
  //if(window.innerWidth ){
    //Non-IE
    w = window.innerWidth;
    h = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    w = document.documentElement.clientWidth;
    h = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    w = document.body.clientWidth;
    h = document.body.clientHeight;
  }
  //CSS style change
  if (w<=800 || h<=600) {
	  setCSS('for800');
	  } else {
		  setCSS('for1024');}
}
window.onresize = checkWindow;