// JavaScript Document
var bgimg;
var bgoud;
var init = function(img) {
  if (arguments.callee.done) return;
  arguments.callee.done = true;
  //bgimg = document.getElementById('bg').firstChild.nextSibling;
  
  bgimg = document.getElementById('imgid');
  bgoud = document.getElementById('bg');
  //if (!bgimg) return;
  try{
  	bgimg.onload = resizeBg;
  	bgimg.src = img;
   if (window.addEventListener) window.addEventListener('resize', resizeBg, false);
  else if (window.attachEvent) window.attachEvent('onresize', resizeBg);
  else window.onresize = resizeBg;
  }catch(err){
  }
  
  
  

  
}

var resizeBg = function() {
	
  var w = document.body.clientWidth || document.documentElement.clientWidth;
  var h = document.body.clientHeight || document.documentElement.clientHeight;
  
  if (bgimg.width !== w) {
    bgoud.style.left = '0';
    bgoud.style.top = '0';
    bgimg.height = (w / bgimg.width) * bgimg.height;
    bgimg.width = w;
  }
  if (bgimg.height < h) {
    bgimg.width = (h / bgimg.height) * bgimg.width;
    bgimg.height = h;
    bgoud.style.left = '-' + ((bgimg.width - w) / 2) + 'px';
  }else if (bgimg.height > h) {
    bgoud.style.top = '-' + ((bgimg.height - h) / 2) + 'px';
  }
}

/*
if (document.addEventListener) document.addEventListener("DOMContentLoaded", init, false);

if (/KHTML|Webkit|iCab/i.test(navigator.userAgent)) {
	var khtmltimer = window.setInterval(function() {
		if (/loaded|complete/.test(document.readyState)) {
  		window.clearInterval(khtmltimer);
  		init();
		}
	}, 10);
}


*/

function disableSelection(target){
try{
if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none"
else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
target.style.cursor = "default";
}catch(err){
}

}
