var activeStyle = 'main';
function init() {
  checkBrowserWidth();

  if (document.images) {
    var agt = navigator.userAgent.toLowerCase();
   	iswin = (agt.indexOf("win")>-1);
  	var b = navigator.appName;
  	if (b=="Microsoft Internet Explorer" && iswin) { // Preload(png alpha)
      img1 = new Image(); img1.src = 'http://www.adonaitzvaoth.com/skins/leftKant.png'
      img2 = new Image(); img2.src = 'http://www.adonaitzvaoth.com/skins/rightKant.png'
      img3 = new Image(); img3.src = 'http://www.adonaitzvaoth.com/skins/positionKant.png'
      img4 = new Image(); img4.src = 'http://www.adonaitzvaoth.com/skins/SuperListLeft.png'
      img5 = new Image(); img5.src = 'http://www.adonaitzvaoth.com/skins/SuperListRight.png'

      img6 = new Image(); img6.src = 'http://www.adonaitzvaoth.com/skins/default/logo.png'

      img7 = new Image(); img7.src = 'http://www.adonaitzvaoth.com/skins/small/logoSmall.png'
      img8 = new Image(); img8.src = 'http://www.adonaitzvaoth.com/skins/small/nameSmall.png'
    }
  }
}



function checkBrowserWidth() {
  docheck = true;
  var agt = navigator.userAgent.toLowerCase();
 	ismac = (agt.indexOf("mac")>-1);
  if (ismac) {
  	if (navigator.appName == "Microsoft Internet Explorer") docheck = false;
  }

  if (docheck) {
  	var theWidth = getBrowserWidth();
  	if (theWidth > 820)	{
      if (activeStyle != 'main') {
    		setStylesheet("main");
        activeStyle = 'main';
      }
  	}	else {
      if (activeStyle != 'small') {
    		setStylesheet("small");
        activeStyle = 'small';
      }
  	}
  }


	return true;
}

function getBrowserWidth() {
	if (window.innerWidth) {
		return window.innerWidth;
	}
	else if (document.documentElement && document.documentElement.clientWidth != 0) {
		return document.documentElement.clientWidth;
	}
	else if (document.body) {
		return document.body.clientWidth;
	}

	return 0;
}




function setStylesheet(styleTitle) {
	var currTag;

	if (document.getElementsByTagName) {
		for (var i = 0; (currTag = document.getElementsByTagName("link")[i]); i++) {
			if (currTag.getAttribute("rel").indexOf("style") != -1 && currTag.getAttribute("title")) {
				currTag.disabled = true;

				if(currTag.getAttribute("title") == styleTitle) {
          defaultStatus = 'Style: ' + styleTitle;
					currTag.disabled = false;
				}
			}
		}
	}
	
	return true;
}



onload = init;
onresize = checkBrowserWidth;
